backbone.js - require.js loading bootstrap undefined -


my main.js below

requirejs.config({ //by default load module ids ../js baseurl: '../js', paths : {     'jquery': 'libs/jquery',     'underscore': 'libs/underscore',     'backbone': 'libs/backbone',     'bootstrap': 'libs/bootstrap' }, shim: {     'jquery': {         exports: '$'     },     'backbone': {         //these script dependencies should loaded before loading         //backbone.js         deps: ['jquery', 'underscore'],         //once loaded, use global 'backbone'         //module value.         exports: 'backbone'     },     'underscore': {         exports: '_'     },     'bootstrap': {         deps: ['jquery'],         exports: 'bootstrap'     } } }); define(     ['jquery', 'backbone','underscore', 'bootstrap'],      function (j, b,  u, boot) {         console.log('jquery', j);         console.log('backbone', b);         console.log('underscore',u);         console.log('bootstrap', boot);     } );  

and console image this:

enter image description here

when click on x sign in alert, disappear. so, think bootstrap.js loaded correctly. however, says undefined in console. can make me clear bootstrap.js loaded correctly , safe use? , why saying undefined while rest of defined in console.

as jquery, backbone, , underscore export global variables used elsewhere, while bootstrap take existing jquery object , add plugins object, hence won't export anything.

so, if try receive in define callback, ideally undefined. if you've used bootstrap component on page , if working means bootstrap integrated.

from requirejs shim docs

for "modules" jquery or backbone plugins not need export module value, shim config can array of dependencies:

requirejs.config({   shim: {     'bootstrap': ['jquery']   } }); 

so, if want, can declare bootstrap specified in docs.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -