How could I access to part of localStorage data an

2019-08-30 06:11发布

I use localStorage to save the app data of my Backbone app. In my router, I use this.collection.fetch() to get the data from localStorage and render them. But this.collection.fetch() actually will fetch all the data in my localStorage space and render them all in View. What I want to do is to get the localStorage data first and filter them, then use these filtered part to render the View. Is it possibile to do this?

1条回答
趁早两清
2楼-- · 2019-08-30 06:24

It's because you probably bind the view to the reset event of the collection.

this.collection.on('reset', this.render, this)

If you want to take more control against what to render (manual rendering not binded to events), you should avoid binding that events and call render method when you need it after doing proper filtering of collection.

查看更多
登录 后发表回答