Backbone.ModelBinder
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:Simple, flexible and powerful Model-View binding for Backbone.
Special thanks to [Derick Bailey](http://lostechies.com/derickbailey) for creating predecessor to this plugin.
I've been able to reuse unit tests he created for his [Backbone.ModelBinding](https://github.com/derickbailey/backbone.modelbinding) plugin.

### Rationale
Backbone is a great platform for writing client side applications but I've found that as views grow in complexity, synchronizing my models and views can be a pain.
I've spent the past few months trying to use existing view-model binding libraries that others were kind enough to create and share with the world.
Unfortunately in the majority of my backbone application I wasn't able to leverage the existing view-model binding libraries due to various limitations.

I created a new `Backbone.ModelBinder` class that I have leveraged in the majority of a large client side application.
The ModelBinder class helped me remove a lot of cluttered boilerplate code that existed to synchronize my models and views.
As my application became more asynchronous, the ModelBinder saves me from a lot of pain by automatically displaying model attributes in the view as they are asynchronously loaded.
Hopefully you'll find the ModelBinder useful too.

The `Backbone.ModelBinder` class:

* Is as simple as possible yet still flexible and powerful
* Leverages the exact same jQuery syntax that the Backbone.View event blocks use
* Allows you to define type formatting and type conversion in your bindings
* Provides a simple javascript only solution rather than mixing binding syntax in html templates and javascript files.  I personally find mixing binding logic in my html files to be messy and confusing.

You can use this ModelBinder class to bind backbone model attributes to:

* Read-only html elements such as ``, `
` etc. * Html element attributes such as enabled, displayed, style etc. * Editable form elements such as ``, `