0
下面是我的html页面/视图页面包括我的问题是我如何包括我的切换功能,在我看来/ JS文件Backbone.js的如何包括自定义功能
camp.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;
});
但在控制台中我不断获取收到错误的切换没有定义.. – Rajeev
我已经改变了阿洛斯我的看法..Please请参阅视图中的编辑,js ..错误仍然存在 – Rajeev
@Rajeev从输入中删除内嵌Javascript,控制台显示什么错误? –