Bug: nestable loads before jQuery

On the Menu Item List edit page that contains the drag & drop feature, I would get the error “cannot read property ‘fn’ of undefined” from the nestable plugin. It wouldn’t happen always…I saw it on one of my development sites but not the other. I determined the problem is that nestable is trying to initialize before jQuery has loaded, therefore jQuery is undefined.
I fixed the issue and recommend that you send it to your developers to implement also. In the file “Ubertheme/UbMegaMenu/view/adminhtml/requirejs-config.js”, change the contents to:
 

/**

* Copyright © 2016 Ubertheme.com All rights reserved.

*/

var config = {

    paths: {

        nestable: 'Ubertheme_UbMegaMenu/js/jquery.nestable.min',

        ubImportCategories:  'Ubertheme_UbMegaMenu/js/ub-import-categories'

    },

    shim: {

        'nestable':{

            'deps':['jquery']

        }

    }

};

The shim property in the requirejs-config allows you to determine the load order of modules. See the “RequireJS and jQuery Plugins” section at the end of Alan Storm’s article for further explanation of the solution. http://alanstorm.com/magento_2_and_requirejs/
 

1 answer

Please login or Register to Submit Answer

Written By

Comments