我有一个集合,我想从中删除一个模型并让它实时同步:
var ClientCollection = Backbone.Firebase.Collection.extend({
model: Client,
url: "https://<my-firebase-url>.firebaseio.com",
autoSync: true
});
我使用我的clear
函数从集合 veiw 中尝试了以下内容:
var ClientView = Backbone.View.extend({
tagName: "li",
className: "list-group-item",
template: _.template("<%= name %>"),
events: {
"click .destroy" : "clear"
},
initialize: function() {
this.listenTo(this.model, "change", this.render);
},
render: function() {
this.$el.html(this.template(this.model.toJSON()));
return this;
},
clear: function() {
this.model.remove();
},
});
但是,这只会从 DOM 中删除模型。
如何从服务器和 DOM 中删除模型?