Created
August 22, 2013 02:45
-
-
Save kjirou/6302644 to your computer and use it in GitHub Desktop.
It's bugged. findAll() can't find all localStorage keys of some Model. In the case, Backbone.LocalStorage requires to use Collection.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Clear all data in localStorage about some model class. | |
@clearLocalStorage = (modelClass) -> | |
# Must create a model instance for to sync localStorage.records. | |
# (But is also a target that you want to delete it! | |
# Backbone.LocalStorage is not good so much...) | |
accessor = new modelClass | |
for modelAttrs in accessor.localStorage.findAll() | |
target = new modelClass(id: modelAttrs.id) | |
accessor.localStorage.destroy target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment