2013-12-17 28 views
2

我正在爲我的項目(https://izify.com/)使用jquery,backbonejs,underscorejs和bootstrap 3。這是我的源代碼https://github.com/datomnurdin/izify-template。點擊按鈕後,我無法打開Goog​​le瀏覽器導航欄。Bootstrap 3 + backbonejs - 切換導航無法打開

這是toogle nav的屏幕截圖。

enter image description here

我offcanvas.js

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

有當backbonejs集成任何問題嗎?

我把模板從這裏,http://getbootstrap.com/examples/offcanvas/

演示網站:http://staging.revivalx.com/izify-template/

+0

你檢查控制檯? – Adrift

+0

什麼也沒有發生。檢查這個演示網站。 http://staging.revivalx.com/izify-template/ –

回答

2

如何ABT this..cleaner方式

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; 

}); 
0

我刪除offcanvas.js

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

,並把這個行代碼

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

成HomeView.js

define([ 
    'jquery', 
    'underscore', 
    'backbone', 
    'text!templates/home/homeTemplate.html' 
], function($, _, Backbone, homeTemplate){ 

    var HomeView = Backbone.View.extend({ 
    el: $("#page"), 

    render: function(){ 
     this.$el.html(homeTemplate); 

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

    }); 

    return HomeView; 

}); 

它工作正常。