Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#10668 closed enhancement (invalid)

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').

Change History (2)

comment:1 Changed 7 years ago by dmethvin

Resolution: invalid
Status: newclosed

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

comment:2 Changed 7 years ago by rodneyrehm

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/

Note: See TracTickets for help on using tickets.