2

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?

enter image description here

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

2

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');
});
0

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.

6
  • 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 updated
    – Zinat
    Commented Aug 3, 2017 at 6:46
  • please do static-content deploy and clear cache and then check. It may works. Commented Aug 3, 2017 at 6:48
  • I did several times... may you check the edit part, I provided more info. Tnx
    – Zinat
    Commented Aug 3, 2017 at 6:52
  • your code should look like this require(['jquery', 'jquery/ui'], function($){ alert('Test'); });
    – Aman Alam
    Commented Aug 3, 2017 at 6:56
  • if you js file you need to include jquery/ui by adding argument in require in your custom js file.
    – Aman Alam
    Commented Aug 3, 2017 at 6:58
0

calling the js is incorrect. Please define the js like this in phtml

require(['jquery','jQueryCustom'], function($){

// custom codel

 }
1
  • That's my jquery.no-conflict.js not the one in phtml file
    – Zinat
    Commented Aug 3, 2017 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.