I don't get why adding my custom js file causes below issue. Please help understand the cause. Let me know if more details should be provided here.
Is it dependency issue?
edit: My requirejs-config.js in module
var config = {
"paths":
{
"jQueryCustom": "myVendor_myModule/js/jquery.custom",
"jqueryNoConflict": "myVendor_myModule/js/jquery.no-conflict",
}
};
My jquery.no-conflict.js in module
define(['jQueryCustom'],function ()
{
return jQuery.noConflict(true);
});
3 Answers 3
In your custom js you just need to add jquery/ui in require section and it will work.
require(['jquery', 'jquery/ui'], function($){
alert('Test');
});
May be it is a jquery conflict issue. Call a custom js via requirejs-config.js instead of xml or phtml file.
Refer below links for using requirejs-config.js
Use require-config.js to load files needed on all pages
Hope it will works.
-
Actually I'm adding the js file through requirejs-config.js in my module and calling it in my custom theme phtml file, but I'll check the details with the link you provided... keep here updatedZinat– Zinat2017年08月03日 06:46:02 +00:00Commented Aug 3, 2017 at 6:46
-
please do static-content deploy and clear cache and then check. It may works.SathishrajRaju– SathishrajRaju2017年08月03日 06:48:09 +00:00Commented Aug 3, 2017 at 6:48
-
I did several times... may you check the edit part, I provided more info. TnxZinat– Zinat2017年08月03日 06:52:25 +00:00Commented Aug 3, 2017 at 6:52
-
your code should look like this
require(['jquery', 'jquery/ui'], function($){ alert('Test'); });Aman Alam– Aman Alam2017年08月03日 06:56:27 +00:00Commented Aug 3, 2017 at 6:56 -
if you js file you need to include
jquery/uiby adding argument in require in your custom js file.Aman Alam– Aman Alam2017年08月03日 06:58:41 +00:00Commented Aug 3, 2017 at 6:58
calling the js is incorrect. Please define the js like this in phtml
require(['jquery','jQueryCustom'], function($){
// custom codel
}
-
That's my jquery.no-conflict.js not the one in phtml fileZinat– Zinat2017年08月03日 07:05:16 +00:00Commented Aug 3, 2017 at 7:05