Skip to content Skip to sidebar Skip to footer

Using Require.js With Twitter Boostrap Api And Backbone

Regarding this entry Loading Backbone and Underscore using RequireJS it is quite clear to me how do I configure Backbone-specific scripts and JQuery. But how do I: configure Twit

Solution 1:

In addition to what you learned about the path config option, you should also review the shim config option http://requirejs.org/docs/api.html#config-shim.

Many plugins are not AMD ready so you have two options. Either configure it as a shim (suitable for most plugins), or write your own adapters like the efforts at https://github.com/amdjs

Simple example:

require.config({
    shim: {
        'bootstrap': ['jquery'], // no exports'underscore': { exports: '_' }, // no dependencies'backbone.layoutmanager': {
            deps: ['backbone']
            exports: 'Backbone.LayoutManager'
        } // a mix of exports and dependencies
     }
});

For something like json2 which has no dependencies and only activates if the browser has no native implementation, you can simply list it as a dependency of your main application's require without a wrapper / shim.

Post a Comment for "Using Require.js With Twitter Boostrap Api And Backbone"