下面是我的 html 页面/views 页面包括我的问题是如何在我的 view/js 文件中包含我的切换功能
营地.html
<table cellpadding="0" cellspacing="0" border="0" class="camp" id="camp">
<tr>
<th width="5%"><input type="checkbox" onChange="toggle(this)" class="tick_mark" /></th>
<th width="45%">Campaign Name</th>
</tr>
</table>
EDIT
意见/camp.js
define([
'jquery',
'underscore',
'backbone',
'text!templates/camp.html',
'collections/camp',
'views/campviews',
'constants'
], function( $, _, Backbone, allcamp, Campaignscollection, Campaignsview, Constants ) {
if (!CM.Views) {
CM.Views= {};
}
CM.Views.camp = Backbone.View.extend({
template: _.template(allcamp),
initialize: function() {
this.on("change:name", function(model){
var name = model.get("name"); // 'Stewie Griffin'
alert("Changed my name to " + name );
});
_self = this;
this.campaigns = new Campaignscollection();
this.campaignsview = new Campaignsview({collection:this.campaigns});
this.campaigns.fetch({
success: function () {
// _self.render();
$(_self.el).find("#camp").append(_self.campaignsview.render().el);
}
});
},
events:{
'change .tick_mark': 'toggle'
},
toggle : function(){
alert("//");
},
toggle: function( newChildsName ){
//this.set({ child: newChildsName });
alert("in toggle");
},
render: function() {
$(this.el).html(this.template());
return this;
}
});
return CM.Views.camp;
});