嗨,我对backbone.js 有点陌生
有没有办法从集合中删除一个项目(并且只是那个项目)并且不必刷新列表。相反,仅从视图和集合中删除该项目,并且视图集合不会发生刷新/重新渲染。或者甚至有可能吗?
这是我的代码片段:
var DateModel = Backbone.Model.extend({
defaults: function() {
return {
index: '',
valueFrom: '',
valueTo: '',
status: '',
showText: '',
text: ''
}
},
});
var DateList = Backbone.Collection.extend({
model: DateModel
});
var dateList = new DateList();
var DateView = Backbone.View.extend({
model: new DateModel(),
...
});
var DateListView = Backbone.View.extend({
model: dateList,
el: $('#date-list-container'),
initialize: function() {
this.listenTo(this.model, 'add', this.render);
this.listenTo(this.model, 'remove', this.render);
this.listenTo(this.model, 'reset', this.render);
},
render: function() {
// code for rendering here...
_.each(this.model.models, function(date){...});
}
});