バックボーンでの収集と表示
var studentmodel = Backbone.Model.extend();
var studentcollection = Backbone.Collection.extend({
model : studentmodel,
url : 'http://localhost/bb/data.JSON',
parse : function(response){
//console.log(response.data);
return response.data;
//return response;
},
});
var studentlistview = Backbone.View.extend({
tagName : "ul",
className : "studentlistul",
initialize : function(){
this.model.bind("reset", this.checkEvent,this);
this.model.bind("add", this.checkEvent,this);
},
checkEvent : function(){
$(this.el).html("");
_.each(this.model.models, function(student){
$(this.el).append(new studentListItemView({ model : student}).render2().el);
}, this);
$('#studentlistdiv').html($(this.el));
return this;
} });
このモデルとその作業にアイテムを追加しようとすると、私の質問は、レンダー fn 内で this.model.bind("add", this.checkEvent,this) この evt が発生している間にイベント タイプを取得する方法です。checkEvent内で、イベントのタイプ、つまり追加またはリセットのどちらが発生したかを取得するにはどうすればよいですか。これは私の質問です 助けてください