sábado, 6 de septiembre de 2014

el atributo data en JQUERY HTML5

http://api.jquery.com/data/
http://stackoverflow.com/questions/7261619/jquery-data-vs-attr

interesante

If you are passing data to a DOM element from the server, you should set the data on the element:
<a id="foo" data-foo="bar" href="#">foo!</a>
The data can then be accessed using .data() in jQuery:
console.log( $('#foo').data('foo') );
//outputs "bar"
However when you store data on a DOM node in jQuery using data, the variables are stored in on the nodeobject. This is to accommodate complex objects and references as storing the data on the node element as an attribute will only accommodate string values.
Continuing my example from above:
$('#foo').data('foo', 'baz');

console.log( $('#foo').attr('data-foo') );
//outputs "bar" as the attribute was never changed

console.log( $('#foo').data('foo') );
//outputs "baz" as the value has been updated on the object


http://stackoverflow.com/questions/12405874/kendo-ui-grid-display-grid-on-a-link-click

No hay comentarios:

Publicar un comentario