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:
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.