我正在尝试删除我在主干中创建的模型。我并不是要取消模型本身。
这就是我所拥有的:首先对代码进行茉莉花单元测试
it("should delete the current Box ", function () {
var myContainer = new App.Container();
var myBox = new App.Box();
myBox.setTitle("The First Box");
expect(myBox.attributes.title).toBeDefined();
**myContainer.deleteBox(myBox);**
expect(myBox.attributes.title).toBeUndefined();
});
现在代码:
App.Container = Backbone.Model.extend({
defaults: {
type: "1.0",
selectedBox: 0,
boxes: [],
labels: [],
},
deleteBox: function () {
this.destroy({
success: function() {
console.log("the box has been removed");
//Array reindexed
}
});
}
});
这没用。茉莉花单元测试失败,我想我必须了解如何删除骨干给出的 cid 处的对象。我不知道该怎么做。有什么建议么?