主干/淘汰通常用于单页应用程序.因此,虽然jQuery是一个工具箱,可以用于任何网页,但主干是针对特定类型的应用程序的,可以帮助您组织代码.至少在我的经验中,构建单页应用程序的最大挑战之一是保持代码干净和模块化,主干网在这方面有很大帮助.
The characteristics of a typical backbone app are:
- 本质上是静态的html页面,服务器上没有生成任何内容
- Server acts as a json REST api, which provides the content for the app
- The dom elements to display the data are created with javascript in backbone views, using jQuery and various templating libraries to help
- 与服务器的通信以及应用程序不同部分之间的通信都是通过主干模型完成的
关于你关于在多个页面上保持数据同步的问题,我本能的回答是,你不需要多个页面:用户可能会感觉到页面正在更改,url栏中的地址会因pushState功能而更改,但从技术上讲,整个应用程序是一个页面.
The biggest advantages of this kind of approach are a smooth user experience (no reloading pages), good caching support as everything except the json data is static content, for mobile targets the possibility to turn the web app into a mobile app with phoneGap (because everything except json is static).