Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#13440 closed bug (duplicate)

.data() is inconsistant when reading from data- attributes

Reported by: BrianMinister@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

Description

when a data- attribute is rendered at the server and sent, it seems that it is inconsistant that the attribute can be read by .data(). However .attr() can always read that attribute when .data() cannot.

When the data- attribute is created in script, then .data() can read it all the time.

See http://brianscodeextreme.blogspot.com/search/label/jQuery for details and other links.

NOTE: I have only tested this with IE 9 and 10, on pages tagged at HTML 5.

Change History (5)

comment:1 Changed 7 years ago by dmethvin

Resolution: notabug
Status: newclosed

There is no test case or explanation of what the "failure" is here but using .attr() is correct if you always want the attribute and not the internal cached data. See http://www.learningjquery.com/2011/09/using-jquerys-data-apis

comment:2 Changed 7 years ago by Rick Waldron

Resolution: notabug
Status: closedreopened

comment:3 Changed 7 years ago by Rick Waldron

Resolution: duplicate
Status: reopenedclosed

Duplicate of #13130.

comment:4 Changed 7 years ago by Rick Waldron

@BrianMinister you should update your blog to indicate that jQuery's API docs are very clear about this: http://api.jquery.com/data/#data-html5

comment:5 Changed 7 years ago by BrianMinister@…

Thank you. Editing my blog accordingly. I made wrong assumptions on how older scripts are running on newer version of the library.

Note: See TracTickets for help on using tickets.