mulla.azzi
mulla.azzi

Reputation: 2676

Bootstrap3 Navbar toggle is not working with requirejs

I am designing a web app using BackboneJS, RequireJS and Bootstrap. When i am reducing screen size, the navbar is collapsing but the click event is not working on the toggle button. Earlier also i had faced the same issue when i was not using RequireJS. At that time i had included Jquery and BootstrapJS in the Head tag and it worked for me. Now as i am using RequireJS and facing the same issue. Can anyone please help me with this? I am attaching the config code for Require below

require.config({
    paths: {
        jquery: '../lib/jquery',
        underscore: '../lib/underscore',
        backbone: '../lib/backbone',
        router: 'router',
        bootstrap: "//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min"
    },
    shim: {
        'backbone': {
            deps: ['underscore', 'jquery'],
            exports: 'Backbone'
        },
        'underscore': {
            exports: '_'
        },
        'bootstrap': {
            deps: ['jquery']
        }
    }
});

Upvotes: 1

Views: 450

Answers (1)

mulla.azzi
mulla.azzi

Reputation: 2676

Actually it was a silly mistake. Bootstrap was not included in the module.

define([
  'jquery',
  'underscore',
  'backbone',
  'router',
  'bootstrap'
  ], 
  function ($, _, Backbone, Router) {
      var initialize = function () {
          // Pass in our Router module and call it's initialize function
          Router.initialize();
     }
  return {
      initialize: initialize
  };
});

Upvotes: 2

Related Questions