I'm currently utilizing Backbone.js along with Lawnchair and backbone.lawnchair.js.
My query pertains to the right approach for "emptying" a collection, both in the application itself and in localStorage.
At present, I am implementing a method similar to the following:
Favorites.Collection = Backbone.Collection.extend({
model: Favorites.Model,
lawnchair: new Lawnchair({ name: "favorites" }, function(e){}),
empty: function(){
this.lawnchair.nuke();
this.fetch();
}
});
This process involves removing elements from localStorage using the nuke method provided by Lawnchair, followed by fetching again from localStorage. However, I find this procedure somewhat cumbersome and wonder if there might be a more efficient alternative.
Cheers!