Search code examples
jquerytwitter-bootstrapbackbone.js

Bootstrap 3 + backbonejs - Toggle nav not opening


I am using jquery, backbonejs, underscorejs and bootstrap 3 for my project (https://izify.com/). This is my source code https://github.com/datomnurdin/izify-template. I can't open toogle nav when click the button.

This is screenshot for toogle nav.

enter image description here

My offcanvas.js

$(document).ready(function() {
  $('[data-toggle=offcanvas]').click(function() {
    $('.row-offcanvas').toggleClass('active');
  });
});

Is there any problem when integrate with backbonejs?

I take the template from here, http://getbootstrap.com/examples/offcanvas/

Demo site: http://staging.revivalx.com/izify-template/


Solution

  • how abt this..cleaner way

    define(['jquery', 'underscore','backbone','text!templates/home/homeTemplate.html'], function($, _, Backbone, homeTemplate){
    
     var HomeView = Backbone.View.extend({
     el: $("#page"),
    
     events: {
        'click [data-toggle=offcanvas]' :'toggleClass'
     }, 
    
     render: function(){
        this.$el.html(homeTemplate);
     },
    
     toggleClass: function (e) {
    this.$('.row-offcanvas').toggleClass('active');
     }
    
    });
    
     return HomeView;
    
    });