Service Portal: Javascript error in your browser console
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 02:14 AM
Hello!
We have a catalog client script that uses $j. This works in the backend but in the Service Portal, it shows the error below.
Is there an alternative of using $j in a catalog client script that works in both backend and Service Portal? The client script is:
$j('#loc).change(function() {
var locVal = $j('#loc').val();
locVal = locVal .substring(0,locVal.indexOf(':'));
g_form.setValue('location',locVal);
});
$j('#zipcode').change(function() {
var zipcodeVal = $j('#zipcode').val();
zipcodeVal = zipcodeVal.substring(0,zipcodeVal.indexOf(':'));
g_form.setValue('zipcode',zipcodeVal);
});
}
Thank you.
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2023 09:32 PM
Hi @ramirch ,
Can you try with the below script
var $j = jQuery.noConflict();
$j(document).ready(function() {
$j('#loc').change(function() {
var locVal = $j('#loc').val();
locVal = locVal.substring(0, locVal.indexOf(':'));
g_form.setValue('location', locVal);
});
$j('#zipcode').change(function() {
var zipcodeVal = $j('#zipcode').val();
zipcodeVal = zipcodeVal.substring(0, zipcodeVal.indexOf(':'));
g_form.setValue('zipcode', zipcodeVal);
});
});
The jQuery.noConflict() function is called to avoid conflicts with other libraries that may be using the "$" shorthand.
Regards,
Shravan
Please mark this as helpful and correct answer, if this helps you
Shravan
Please mark this as helpful and correct answer, if this helps you