Magento 2 – Fix Cannot Read Property ‘ui’ of Undefined

jquerymagento2ui

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

Best Answer

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