Skip to content

Instantly share code, notes, and snippets.

@demogar
Created April 28, 2011 18:33
Show Gist options
  • Select an option

  • Save demogar/946960 to your computer and use it in GitHub Desktop.

Select an option

Save demogar/946960 to your computer and use it in GitHub Desktop.
chain js javascript
$(document).ready(function() {
var array = [
{first:'Isaac', last:'Newton', id: '1'},
{first:'Johannes', last:'Keppler', id:'2'},
{first:'Alessandro', last:'Volta', id: '3'},
{first:'Blaise', last:'Pascal', id: '4'}
];
$('#persons')
.items(array)
.chain({
self: {
value: '{id}',
content: '{first} {last}'
}
});
$("#some_name").click(function() {
actualizar();
});
});
function actualizar()
{
var resultado = [
{first:'Isaac', last:'Newton', id: '1'},
{first:'Johannes', last:'Keppler', id:'2'}
];
$('#persons')
.items("replace", resultado);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment