Loading twitter bootstrap using browserify -


how use twitter bootstrap in browserify? installed bootstrap-browserify, , tried using in code

later in code, have code trying patch modal dialog function of bootstrap, throws error.

this how code looks like:

var bootstrap = require('bootstrap-browserify');  $(document).ready(function () {      $.fn.modal.constructor.prototype.enforcefocus = function () {         var = this;         $(document).on('focusin.modal', function (e) {             if ($(e.target).hasclass('select2-input')) {                 return true;             }              if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {                 that.$element.focus();             }         });     }; } 

i new browserify , using first time. doing wrong?

first you'll have install bootstrap, jquery, , browserify-shim. prefer install these bower (because of flat dependency structure) use npm. browserify-shim section of package.json config:

  "browserify": {     "transform": [       "browserify-shim"     ]      },     "browser": {     "jquery": "./bower_components/jquery/dist/jquery.min.js",     "bootstrap": "./bower_components/bootstrap/dist/js/bootstrap.min.js"   },     "browserify-shim": {     "jquery": "$",     "bootstrap": {       "depends": [         "jquery: jquery"       ]        }      },   

the way prefer install bootstrap (and dependency jquery) install these global scope. therefore, somewhere in code "browserified" i'll put following:

$ = jquery = require('jquery'); require('bootstrap'); 

note i'm not using var here. means $, jquery, , necessary bootstrap javascript available on window object.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -