Backbone.js的和jQuery [英] Backbone.js and jQuery

查看:236
本文介绍了Backbone.js的和jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据悉,主干处理所有的更高层次的抽象,而jQuery的或类似的库与DOM工作,规范活动等..

It is said that Backbone handles all the higher level abstractions, while jQuery or similar libraries work with the DOM, normalize events and so on..

可能有人请帮助我了解任何简单的实例本声明。

Could someone please help me understand this statement with any simple practical example.

像骨干MVC框架而且重要特征之一,基因敲除是,它保持模型(数据),并在同步视图。但是,这似乎是特定于一个页面级,而不是在整个应用程序。所以我们可以有模型/数据,并在多个页面同步的观点。(一种全球)

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是可以与任何网页使用的工具箱,骨干是为特定类型的应用程序,并帮助你组织你的code吧。至少在我的经验,在构建单页的应用程序的最大挑战之一是保持code干净和模块化,骨干帮了不少忙这个。

Backbone / Knockout is typically used for single page applications. So while jQuery is a toolbox that can be used with any webpage, Backbone is meant for a specific type of application and helps you organize your code for it. At least in my experience one of the biggest challenges in building a single page app is keeping the code clean and modular, and backbone helps a great deal with this.

典型骨干应用的特性是:

The characteristics of a typical backbone app are:


  • 本质上是静态的HTML页面,在服务器上生成的任何

  • 服务器作为一个JSON REST API,它提供了对应用程序
  • 内容
  • 是用JavaScript创建的骨干视图来显示数据的DOM元素,使用jQuery和各种模板库,以帮助

  • 与服务器以及应用程序的不同部分之间的通信是通过骨干机型做

关于你提到的关于保持在多个页面同步的数据问题,我本能的答案是,你并不需要多个页面:用户可能会认为该页面是变化的,在地址栏的地址变化得益于pushState的功能,但在技术上对整个应用程序是一个页面。

Regarding your question about keeping the data synced across multiple pages, my instinctive answer is that you don't need multiple pages: the user may perceive that the page is changing, the address in the url bar changes thanks to pushState functionality, but technically the entire app is one page.

这种方法的最大优点是流畅的用户体验(不重新加载页面),良好的缓存支持,除了JSON数据一切都是静态的内容,移动目标转向Web应用程序到移动应用的可能性PhoneGap的(因为除了JSON一切都是静态的)。

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).

这篇关于Backbone.js的和jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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