据说主干处理所有更高级别的抽象,而jQuery或类似的库处理DOM、规范化事件等等..

有人能用简单的实例来帮助我理解这句话吗.

Also one important feature of MVC framework like Backbone, Knockout is that it keeps the model (data) and the view in sync. But this seems to be specific at a page-level and not across the entire application. So can we have the model/data and the view synced across multiple pages..(kind of global)

推荐答案

主干/淘汰通常用于单页应用程序.因此,虽然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).

Jquery相关问答推荐

点击和touch 事件之间的jQuery冲突解决方法

使用 jQuery 时何时/为什么要在变量前加上$?

动态加载 css 样式表在 IE 上不起作用

如何滚动到jQuery中的元素?

元素上的 jQuery Change 事件 - 有什么方法可以保留以前的值?

什么是不使用 jQuery 的经验技术原因?

仅在 _some 字段上通过 Enter 键禁用表单提交

为什么要两次声明 jQuery?

不使用插件的 jQuery 缓动函数

如何在 jQuery 中存储全局值(不一定是全局变量)?

Select select2后触发动作

jQuery计算所有文本字段中的值的总和

jQuery .live() 和 .on() 有什么区别

如何使用 jQuery 为文本对齐动态添加样式

未捕获的 TypeError:data.push 不是函数

jQuery ajax (jsonp) 忽略超时并且不触发错误事件

我想了解 jQuery 插件语法

带有回调ajax json的jQuery自动完成

使用 jQuery 的 removeAttr 删除多个属性

如何使用 jquery 使下拉列表只读?