Deleting Backbone.js models with cid
I am trying to delete a model that I create in backbone. I am not trying
to do away with the model itself.
this is what I have: A jasmine unit test to the code first
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();
console.log(mySlide);
});
Now the code:
App.Container = Backbone.Model.extend({
defaults: {
type: "1.0",
selectedBox: 0,
boxes: [],
labels: [],
},
deleteBox: function (box) {
this.destroy({
success: function() {
console.log("the box has been removed");
//Array reindexed
}
});
}
});
It does not work. the jasmine unit test fails and I think I have to some
how delete the object at the cid given by backbone. Im not sure how to go
about it. any suggestions?
No comments:
Post a Comment