jquery-object-bind
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:
## jQuery object bind plugin v0.5.3

The plugin allows you to link fields of a form to an object.

It's inspired by [jquery-datalink](https://github.com/jquery/jquery-datalink).

Requires jQuery 1.7+ (uses `on`, `off` and `is`)

Any changes to the form fields are automatically pushed onto the object, saving you from writing retrieval code. 
By default, changes to the object aren't pushed back onto the corresponding form field.
You could enable automatic form update, but this feature requires the non-standard `Object.watch` methods witch is only implemented in Gecko.
Eli Grey has developed an [Polyfill](https://gist.github.com/384583) that offers `Object.watch` to all ES5 compatible browser.

This plugin uses [Semantic Versioning](http://semver.org/).

### Features
*   Changes on form fields are automatically pushed onto the object.
*   Converters let you modify the format or type of the value as it flows between the two sides.
*   Custom selectors let you define witch form field is mapped to witch property
*   Supports nested objects.
*   Changes on the object are automatically pushed onto the form field. **Warning:** requires ES5 compatible browser.
*   Custom access function let you modify every type of element (not only form fields)
*   Of course it's possible to disconnect an bound object

### Non-goals
*   Create an object based on form data.

### Basic Example
Fills the form fields with object properties. The default selector function converts the nested object name to the selector `[name="<>-<>"]` for example on `user.name.first` becomes `[name="name-first"]`.
If the user changes any form field value the `user` object is automatically updated.

	
	
### Converter Example This example shows the basic usage of an converter. An converter consists of of an object of the two function `toView` and `toModel`. `toView` converts the object property to the displayed value and `toModel` converts the user input the the stored value. In this example `toView` only passes the object value to the form but `toModel` converts the input to first letter in upper case and the remaining letters to lower case.
### Selector Example Some times the default selector dosn't fit to the requirements. This example shows how to use an different mapping selector and access function. The option `selector` let you specify an function that converts the namespace array to an jQuery selector. The namespace array contains a object name chain of nested objects. For example the `user.id` property has the namespace `['id']` and the `user.name.first` property `['name', 'first']`. The easiest way is to use the `Array.join` method to convert the array to string and then prefix it with `.` or `#`. This example also shows how to use the `accessFn` option. `accessFn` is the method name called on the element to set and get his value. jQuery provides `val` (the defaul value), `html` and `text`.

本源码包内暂不包含可直接显示的源代码文件,请下载源码包。