Skip to content

Instantly share code, notes, and snippets.

@nnarhinen
Created November 26, 2013 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nnarhinen/7666550 to your computer and use it in GitHub Desktop.
Save nnarhinen/7666550 to your computer and use it in GitHub Desktop.
Make your plain javascript objects and arrays observable with just jquery, jsfiddle: http://jsfiddle.net/EeGkU/3/
<p>Observable plain javascript objects with jQuery (rendered with transparency.js)</p>
<ul class="items">
<li class="title"></li>
</ul>
<p>Wait for a few seconds and watch the last item in list</p>
var items = [
{title: "First"},
{title: "Second"},
{title: "Third"}
];
$('.items').render(items);
$(items).on('change', function() { $('.items').render(items); });
setTimeout(function() {
var itm = items[2];
itm.title = 'Changed';
$(itm).trigger('change');
}, 5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment