How to Handle Page Reloads

2019-08-16 09:38发布

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条回答
做自己的国王
2楼-- · 2019-08-16 10:13

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.

查看更多
登录 后发表回答