RequireJS
npm install -g tnpm@2.4.0 --registry=http://registry.npm.alibaba-inc.com
http://segmentfault.com/a/1190000000492238
http://www.cnblogs.com/snandy/archive/2012/05/22/2513652.html
http://www.ruanyifeng.com/blog/2012/11/require_js.html
http://www.cnblogs.com/yexiaochai/p/3214926.html
RequireJS与AngularJS的集成
http://segmentfault.com/a/1190000000492238
http://stackoverflow.com/questions/13377373/shim-twitter-bootstrap-for-requirejs
require.config({ paths: { /* other paths are omitted */ 'bootstrap': '../libs/bootstrap' }, shim: { 'bootstrap/bootstrap-slider': { deps: ['jquery'], exports: '$.fn.slider' }, 'bootstrap/bootstrap-affix': { deps: ['jquery'], exports: '$.fn.affix' }, 'bootstrap/bootstrap-alert': { deps: ['jquery'], exports: '$.fn.alert' }, 'bootstrap/bootstrap-button': { deps: ['jquery'], exports: '$.fn.button' }, 'bootstrap/bootstrap-carousel': { deps: ['jquery'], exports: '$.fn.carousel' }, 'bootstrap/bootstrap-collapse': { deps: ['jquery'], exports: '$.fn.collapse' }, 'bootstrap/bootstrap-dropdown': { deps: ['jquery'], exports: '$.fn.dropdown' }, 'bootstrap/bootstrap-modal': { deps: ['jquery'], exports: '$.fn.modal' }, 'bootstrap/bootstrap-popover': { deps: ['jquery'], exports: '$.fn.popover' }, 'bootstrap/bootstrap-scrollspy': { deps: ['jquery'], exports: '$.fn.scrollspy' }, 'bootstrap/bootstrap-tab': { deps: ['jquery'], exports: '$.fn.tab' }, 'bootstrap/bootstrap-tooltip': { deps: ['jquery'], exports: '$.fn.tooltip' }, 'bootstrap/bootstrap-transition': { deps: ['jquery'], exports: '$.support.transition' }, 'bootstrap/bootstrap-typeahead': { deps: ['jquery'], exports: '$.fn.typeahead' }, } }); require(['domReady', 'app'], function(domReady, app) { domReady(function() { app.init(); }); });
define(['jquery', 'underscore', 'backbone', 'text!templates/photos-list.html'], function($, _, Backbone, html) { var PhotosListView = Backbone.View.extend({ viewImageFullscreen: function(e) { e.preventDefault(); require(['bootstrap/bootstrap-modal', 'text!templates/photo-modal.html'], function(modal, htmlModal) { var modalTemplate = _.template(htmlModal, options); $('body').append(modalTemplate); // setup $(selector + '_modal').modal({ backdrop: true, keyboard: true, show: false }).css({ 'width': function() { return ($(document).width() * 0.55) + 'px'; }, 'margin-left': function() { return -($(this).width() * 0.5); } }); // trigger `modal` $(selector + '_modal').modal('show'); }); // require() call // ...