How to Handle Page Reloads

北慕城南 提交于 2019-12-24 20:11:44

问题


As I understand it the "conventional" way to handle page reloads is to duplicate functionality and presentation on the web stack using its controllers, views, and models. I'd appreciate insight on other (possibly better) ways to handle these situations. As well as feedback on the following two approaches:

  1. Reload the js framework based app/suite on every web (stack) app page thus forcing the js framework to handle all routing and rendering

  2. Use the web stack to route interactions and then use backbone to display views depending on the interactions.

Thanks!


回答1:


IMHO the 2. approach is the one Backbone has born to :)

Following this approach we'll finish with what is called Single Page Application.

But to achieve this in medium-large applications can be very exhausting. You have to deal with complicate Router that has to be in charge of initialize or replacing elements, also you have to take care with memory leaks and ghost Views. You have to define a system to refresh your Collections and Models due you are reusing them in every page, ...

So a combination of both approaches can be also a good idea. You can split your application in modules like: ManagingUsers, ManagingPosts, ManagingMedia, create Single Page applications for these modules, containing index, edit, show, ... actions that don't reload the page, and if you move to another module the page will be reloaded and in company of the whole framework and with a healthy memory reset.



来源:https://stackoverflow.com/questions/11797168/how-to-handle-page-reloads

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