JQuery Two Way bindings (bidirectional data binding plugin)

Source: Internet
Author: User

JQuery Bindings

Https://github.com/petersirka/jquery.bindings

This is a simple jquery two-way binding library. This plug-in connects HTML elements to the model. For web development is a small, powerful cannon.

Simple JQuery, the bindings. This plugin joins HTML elements with a model and in reverse. This plugin was a Little Big cannon for the web development.

  • CLICK here-jcomponent
  • Easy-to-use
  • Minified only one KB (without GZIP compression)
  • Great functionality
  • Great use
  • Works with JQuery 1.9+
  • Works in IE 7+
  • DEMO EXAMPLE

For specific examples, see:

Http://source.858project.com/jquery-bindings-demo.html

Working mode:

Connect HTML elements and JS objects according to the Data-model property.

The value of Data-model is the property name of the JS object.

In the general control INPUTS class selects classes and Textareas controls use two-way binding to take effect; the values of these controls are modified, and the model (the value of the JS object is updated).

How
does it works?
  • Plugin connects a JavaScript object with HTML elements according to Data-model attribute
  • Data-model must contain object property name
  • In INPUTS, selects and Textareas plugin uses, bindings
  • Model is updated if is changed value in a Input/select/textarea or manually

DEMO CODE

HTML attributes:

<DivId="Container"Data-name="My-model-1"><div><InputType=The text"Data-model=The property"/></div><DivData-model=The property"></div><DivData-model="Property.next.property"></div><DivData-model= "Created" data-format= "Your-custom-format" ></div>< div data-model= "tags  "data-custom=" Your-custom-identificator "></div>< Div data-model= "Html" data-encode= "False" ></< Span class= "pl-ent" >div></DIV>         
    • Data-name= "{String}" is a container name
    • Data-encode= "{Boolean}" enable HTML encoding/decoding string (default:true)
    • Data-format= "{String}" calls $.bindings.format () delegate
    • Data-custom= "{String}" calls $.bindings.custom () delegate
$.bindings (' Create ') (model, [template]);

Create bindings.

$(' #form‘).Bindings' Create') ({firstname:' Peter', LastName:' Širka‘ });or (XHR)$(' #form‘).Bindings' Create') ({firstname:' Peter', LastName:' Širka‘ },'/my-form.html‘);or (HTML)$(' #form‘).Bindings' Create') ({firstname:' Peter', LastName: ' širka '},  <input type= "text" data-model= "FirstName"/><span>your FirstName: <b data-model= "First-name" ></ B></span>//or (SELECTOR) $ ( bindings ( ' Create ") ({FirstName  ' peter ' Širka '}, < Span class= "Pl-pds" > ' #template-selector         

JQuery Two Way bindings (bidirectional data binding plugin)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.