0

i am on the way to create a custom module for sliding. But always its driving me crazy on jquery issues. Sometime the js will load and everything will be fine. After sometime, jquery wont get loaded.

var config = {
map: {
    '*': {
             'flexslider': 'Slidermodule_Mymodule/js/jquery.flexslider-min'
    }
} };

and the script looks like

require([ 'jquery', 'flexslider', 'domReady!'], function(){   jQuery(document).ready(function () {
jQuery('.flexslider').flexslider();  });  });

Some time there is no error. Sometime there is error on refresh. Please advise.

2

The flexslider plugin doesn't use an AMD pattern, so you'll have to use a 'shim' to guarantee jQuery as a dependency.

Take a look at Alan Storm's excellent article, he has a whole section dedication to "RequireJS and jQuery Plugins": Alan Storm: Magento 2 and RequireJS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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