Bug Tracker

Modify

Ticket #10668 (closed enhancement: invalid)

Opened 20 months ago

Last modified 20 months ago

Allow jQuery.data() to update data-attributes

Reported by: rodneyrehm Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7
Keywords: Cc:
Blocking: Blocked by:

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

comment:1 Changed 20 months ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

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 20 months 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/

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.