我正在学习BackboneJS。在下面的代码this.at(0).destroy();
:用REST后端我想发出一个HTTP一致DELETEBackboneJS:REST DELETE不会触发destroy()
var Task = Backbone.Model.extend({
defaults: {
name: 'Testing Just',
},
url: 'http://localhost:8080/todos/',
});
var Tasks = Backbone.Collection.extend({
model: Task,
url: 'http://localhost:8080/todos/'
});
var tasks = new Tasks();
tasks.fetch({
context: tasks
}).done(function() {
console.log("Tasks:" + this.length)
console.log(this.at(0).get('name'));
this.at(0).destroy();
console.log("Tasks:" + this.length);
console.log(this.at(0).get('name'));
});
该模型是从集合中删除,但没有休息DELETE发生到后端。 REST后端的删除与'localhost:8080/todos/0'一起使用。 请告诉我缺少的东西。
您的模型有ID吗? –