日期:2014-05-16 浏览次数:20337 次
var CustomView = Backbone.View.extend({
el: $('body'),
events: {
"click .btnClick": "onClick"
},
initialize: function () {
this.render();
},
render: function () {
this.$el.append("<div class='btnClick' style='background-color:red; width:100px;height:100px'></div>");
},
onClick: function () {
console.log('onClick');
}
});
var CustomModel = Backbone.Model.extend({
defaults: {
name: 'test'
}
});
var modelA = new CustomModel();
var modelB = new CustomModel();
var viewA = new CustomView({ model: modelA });
var viewB = new CustomView({ model: modelB });