Tuesday, 6 October 2009

Announcing the release of the jQuery databind plug-in

The databind plug-in allows you to automatically bind the contents of an object in JavaScript (usually retrieved using AJAX/JSON).

Each key in the object is used as an id (.example) selector within the selector provided e.g.

var data = { title: 'Lorem ipsum', text: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.' };
$(document).binddata(data);

<body>
<div>
<p id="title" style="font-weight:bold"></p>
<p id="text"></p>
</div>
</body>

Provides the output visible at http://www.opencomponents.net/databind/example1.htm

More complicated examples include the ability to bind arrays of data and objects to tables and unbind forms into json.

More examples and code can be downloaded from: http://www.opencomponents.net/databind/

No comments: