Answer the question
In order to leave comments, you need to log in
What's wrong with removing models from the Backbone collection?
I can not delete all models from the collection, they are only partially deleted. Stored in LocalStorage. I delete like this:
_.each(myApp.Animals.models, function(animal) {
animal.destroy();
});
myApp.Animals.invoke('destroy');
_.each(myApp.Animals.models, function(animal) {
var animalView = new myApp.AnimalInMyListView({'model': animal});
self.$el.find('table').append(animalView.render().el);
});
addAnimal: function(animal) {
var newAnimal = animal.clone();
newAnimal.set({amount: 1});
myApp.Animals.create(newAnimal);
}
Answer the question
In order to leave comments, you need to log in
Decided like this:
_.each(myApp.Animals.models, function(animal) {
myApp.Animals.models[0].destroy();
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question