如何处理页面重载 [英] How to Handle Page Reloads

查看:116
本文介绍了如何处理页面重载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解,处理页面重新加载的常规"方法是使用其控制器,视图和模型在Web堆栈上复制功能和表示.我希望能有其他(可能更好)的方式来处理这些情况.以及对以下两种方法的反馈:

  1. 因此在每个Web(堆栈)应用程序页面上重新加载基于js框架的应用程序/套件 强制js框架处理所有路由和渲染

  2. 使用Web堆栈来路由交互,然后使用主干来 根据交互显示视图.

谢谢!

解决方案

恕我直言, 2.方法是Backbone诞生的一种方法:)

按照这种方法,我们将以称为单页应用程序结束./p>

但是要在中型应用中实现这一目标可能会非常耗费精力.您必须处理复杂的Router,该复杂的Router必须负责初始化或替换元素,还必须注意内存泄漏和 ghost视图.您必须定义一个系统来刷新您的集合和模型,因为您要在每个页面中重复使用它们,...

因此,将两种方法结合起来也是一个好主意.您可以将应用程序拆分为以下模块:ManagingUsersManagingPostsManagingMedia,为这些模块创建单页应用程序,其中包含indexeditshow,...不包含的操作重新加载页面,如果您移至另一个模块,则将重新加载该页面,并且与整个框架配合进行,并且内存重置正常.

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!

解决方案

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.

这篇关于如何处理页面重载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆