How could I access to part of localStorage data and render them in Backbone app?

淺唱寂寞╮ 提交于 2020-01-07 02:16:32

问题


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.



来源:https://stackoverflow.com/questions/10405963/how-could-i-access-to-part-of-localstorage-data-and-render-them-in-backbone-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!