1

I read many many stackechange threads and internet pages, and still do not get how to do such a simple task as using Javascript. I try my luck...

  • I use 3rd party jQuery Plugins (bxslider, modaal)
  • I have a app.js , that have to be loaded on each pages.

The result of what i have done, is that sometimes it works correctly, sometimes i have javascript errors "Jquery not defined" in modaal or bx, and following it, bx and modaal not defined in my app.

My require-config.js :

var config = {
    map: {
        '*': {
            "modaal": "js/vendor/modaal/dist/js/modaal",
            "bxslider": "js/vendor/bxslider-4/dist/jquery.bxslider",
            "app": "js/app",
        }
    },
    shim: {
        'modaal': {
            deps: ['jquery']
        },
        'bxslider': {
            deps: ['jquery'],
            exports: '$.fn.bxSlider'
        },
        'app': {
            deps: ['jquery', 'bxslider', 'modaal']
        }
    },
    deps: [
        "app"
    ]
};
  • My app.js is surrounded by:

require(['jquery', 'jquery/ui','bxslider','modaal'], function($){ ... });

What do i miss ?

The very cool thing is that it works 70% of the time. It's probably a loading time pb, so dependencies are not ok...

It's getting me crazy to pass so much time on a so much simple task.

edit: i tried many things about the "exports" param of bxslider...

0

I tried everything to not modify my 3rd party librairies, because i find it simply ridiculous.

I had to surround theirs codes by

require(['jquery'], function($){ ... });

If someone has a cleaner functionnal option 100% of the time, i'm all hear...

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.