Created
November 26, 2013 21:26
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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