我是js / backbone的新手,无法让这个点击事件发挥作用。有没有人有任何想法或方向?到目前为止,这是我的代码:
(function(){
window.BtnApp = {
Models: {},
Collections: {},
Views: {}
};
window.template = function(id){
return _.template( $('#' + id).html());
};
BtnApp.Models.Button = Backbone.Model.extend ({
tagName: 'button',
className: 'testbutton'
});
btn = new BtnApp.Models.Button;
BtnApp.Views.Button = Backbone.View.extend ({
events: {
'click h1' : 'logged'
},
cssred: function() {
$('h1').css('color', 'red');
console.log('what se fugg');
return this;
},
logged: function () {
console.log('clicked');
return this;
}
});
btnView = new BtnApp.Views.Button({ model: btn })
})();