Alternative to jQuery .data()?
Posted
by thebossman
on Stack Overflow
See other posts from Stack Overflow
or by thebossman
Published on 2010-05-26T19:05:59Z
Indexed on
2010/05/26
19:11 UTC
Read the original article
Hit count: 196
I'm a big fan of jQuery's .data() method, but I can't always use it. Often times I am rendering html templates that I pass via AJAX and I need to attach metadata to each of the elements in the template. For example:
<ul>
{% for item in itemlist %}
<li metadata="{{ item.metadata }}">{{ item.name }}</li>
{% endfor %}
</ul>
I know attaching attributes to store data is bad practice (and it might not even work in older versions of IE). What is the best practice? Is there a good alternative to this method?
© Stack Overflow or respective owner