Side navigation
#10668 closed enhancement (invalid)
Opened November 04, 2011 02:07PM UTC
Closed November 04, 2011 02:34PM UTC
Last modified November 04, 2011 02:55PM UTC
Allow jQuery.data() to update data-attributes
Reported by: | rodneyrehm | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.7 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
jQuery.data() should be able to (selectively) update data-attributes in order to make something like
$('.selector').data('foobar', 1);
selectable like
$('[data-foobar]').hide();
see modified code and jsFiddle for a possible solution (introducing a new argument 'updateAttr').
Attachments (0)
Change History (2)
Changed November 04, 2011 02:34PM UTC by comment:1
resolution: | → invalid |
---|---|
status: | new → closed |
Changed November 04, 2011 02:55PM UTC by comment:2
I'm terribly sorry to have bothered anyone with this. There's a much simpler (and imho cleaner) solution to this: http://jsfiddle.net/rodneyrehm/XV33m/
Nope. By design we don't write to those attributes under any circumstances, and doing so in a consistent way would affect all the data APIs plus incur a big performance penalty. Use
.attr()
.http://www.learningjquery.com/2011/09/using-jquerys-data-apis