什么是Backbone.js的目的是什么? [英] What is the purpose of backbone.js?

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

问题描述

我试图了解Backbone.js的效用,从它的网站 http://documentcloud.github.com/backbone ,但我仍然无法弄清楚了。

I tried to understand the utility of backbone.js from its site http://documentcloud.github.com/backbone, but I still couldn't figure out much.

任何人能帮助我,解释它是如何工作的,以及它如何能够在写出更好的JavaScript是有益的?

Can anybody help me by explaining how it works and how could it be helpful in writing better JavaScript?

推荐答案

Backbone.js的基本上是一个超级轻型框架,它允许你构成你的Javascript code在 MVC (型号,视图,控制器)的时装,其中...

Backbone.js is basically an uber-light framework that allows you to structure your Javascript code in an MVC (Model, View, Controller) fashion where...

型号是code检索并填充数据的一部分,

Model is part of your code that retrieves and populates the data,

查看是这一模式的HTML重新presentation(观点变更为榜样改变等)

View is the HTML representation of this model (views change as models change, etc.)

和可选的控制器在这种情况下,您可以通过一个URL hashbang保存你的Javascript应用程序的状态,例如:的 http://twitter.com/#search?q=backbone.js

and optional Controller that in this case allows you to save the state of your Javascript application via a hashbang URL, for example: http://twitter.com/#search?q=backbone.js

有些职业选手,我和骨干发现:

Some pros that I discovered with Backbone:


  • 没有更多的JavaScript意大利面:code的组织和分解成使用JAMMIT合并后语义上有意义的.js文件

  • No more Javascript Spaghetti: code is organized and broken down into semantically meaningful .js files which are later combined using JAMMIT

没有更多的 jQuery.data(BLA,BLA):无需存储模型DOM数据,存储数据,而不是

No more jQuery.data(bla, bla): no need to store data in DOM, store data in models instead

事件绑定只是作品

非常有用的下划线工具库

extremely useful Underscore utility library

Backbone.js的code是有据可查的,一个伟大的阅读。睁开眼睛的一些JS code技术。

backbone.js code is well documented and a great read. Opened my eyes to a number of JS code techniques.

缺点:


  • 我花了一段环绕它我的头,并找出如何将它应用到我的code,但我是一个Javascript新手。

下面是使用主干使用Rails的一套伟大的教程作为后端:

Here is a set of great tutorials on using Backbone with Rails as the back-end:

CloudEdit:一个Backbone.js的教程使用Rails:

<一个href=\"http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutorial-by-example/\">http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutorial-by-example/

<一个href=\"http://www.jamesyu.org/2011/02/09/backbone.js-tutorial-with-rails-part-2/\">http://www.jamesyu.org/2011/02/09/backbone.js-tutorial-with-rails-part-2/

P.S。还有这个奇妙的收藏类,可以让你处理的模型和模拟嵌套模型集合,但我不希望从一开始就混淆你。

p.s. There is also this wonderful Collection class that lets you deal with collections of models and mimic nested models, but I don't want to confuse you from the start.

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

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