浙江省高等学校教师教育理论培训

微信搜索“教师资格证岗前培训”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Backbone.js

Backbone.js

Backbone.js gives structure to web applications
by providing models with key-value binding and custom events,
collections with a rich API of enumerable functions,
views with declarative event handling, and connects it all to your
existing API over a RESTful JSON interface.

The project is hosted on GitHub,
and the annotated source code is available,
as well as an online test suite,
an example application,
a list of tutorials
and a long list of real-world projects that use Backbone.
Backbone is available for use under the MIT software license.

You can report bugs and discuss features on the
GitHub issues page,
on Freenode IRC in the #documentcloud channel, post questions to the
Google Group,
add pages to the wiki
or send tweets to @documentcloud.


Backbone is an open-source component of
DocumentCloud.

Downloads & Dependencies
(Right-click, and use "Save As")

Development Version (0.9.2)52kb, Full source, lots of comments
Production Version (0.9.2)5.6kb, Packed and gzipped

Backbone's only hard dependency is
Underscore.js ( > 1.3.1).
For RESTful persistence, history support via Backbone.Router
and DOM manipulation with Backbone.View, include
json2.js, and either
jQuery ( > 1.4.2) or
Zepto.

Introduction

When working on a web application that involves a lot of JavaScript, one
of the first things you learn is to stop tying your data to the DOM. It's all
too easy to create JavaScript applications that end up as tangled piles of
jQuery selectors and callbacks, all trying frantically to keep data in
sync between the HTML UI, your JavaScript logic, and the database on your
server. For rich client-side applications, a more structured approach
is often helpful.

With Backbone, you represent your data as
Models, which can be created, validated, destroyed,
and saved to the server. Whenever a UI action causes an attribute of
a model to change, the model triggers a "change" event; all
the Views that display the model's state can be notified of the
change, so that they are able to respond accordingly, re-rendering themselves with
the new information. In a finished Backbone app, you don't have to write the glue
code that looks into the DOM to find an element with a specific id,
and update the HTML manually
— when the model changes, the views simply update themselves.

If you're new here, and aren't yet quite sure what Backbone is for, start by
browsing the list of Backbone-based projects.

Many of the examples that follow are runnable. Click the play button
to execute them.

posted on 2012-05-07 14:13  lexus  阅读(344)  评论(0编辑  收藏  举报