Closed ashishsajwan closed 7 years ago
You can check my fork for the Real world example as it is not yet an accepted PR https://github.com/ismnoiet/Backbone.localStorage
in the README file
As simple as
var Collection = Backbone.Collection.extend({ localStorage: new LocalStorage('todos') })
var todos = new Collection
todos.fetch()
Thank you @absolux for the direct answer, but if you want really to know how collection items are stored in the localStorage then my solution is here to show you how they are exactly stored in the there, you can also play around with it and see what you get :)
Thanks @ismnoiet for reply. But, why should we direct access localStorage global object instead of the Backbone collection ?
@absolux Good question, my answer is for curious people who want to learn how things are stored, otherwise your answer is the direct one and should be used for real world usage. Because sometimes you need to implement something like backbone collection with your own javascript framework or even just with your javascript code. for short use my solution to learn about real world implementation and your solution if you just need to use it and that's it :). Hope this is a clear answer.
Hi guys,
Thanks for contributing this. I'll be updating the code to ES6 + modules soon which should make the implementation a little more obvious.
Regards, Scott
I have just read this while struggling with how to permanently delete models in local storage. How can I achieve this as all the tricks I can think of failed.
Hi Olu,
Does the usual model.destroy() not do what you need?
On Thu, 11 Apr 2019 at 00:52, Olu Adabonyan notifications@github.com wrote:
I have just read this while struggling with how to permanently delete models in local storage. How can I achieve this as all the tricks I can think of failed.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/jeromegn/Backbone.localStorage/issues/188#issuecomment-481913828, or mute the thread https://github.com/notifications/unsubscribe-auth/AB4PEakxQC5uutEu3WRDuq9MRaW4W01pks5vfnlDgaJpZM4F0DUn .
-- Scott Walton
A good question, me too i was looking for the an answer, and after a little bit of tweaking i found out this: