Skip to main content

Bug Tracker

Side navigation

#13440 closed bug (duplicate)

Opened February 12, 2013 08:17PM UTC

Closed February 12, 2013 08:28PM UTC

Last modified February 12, 2013 08:48PM UTC

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

Reported by: BrianMinister@gmail.com 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.

Attachments (0)
Change History (5)

Changed February 12, 2013 08:27PM UTC by dmethvin comment:1

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

Changed February 12, 2013 08:28PM UTC by rwaldron comment:2

resolution: notabug
status: closedreopened

Changed February 12, 2013 08:28PM UTC by rwaldron comment:3

resolution: → duplicate
status: reopenedclosed

Duplicate of #13130.

Changed February 12, 2013 08:32PM UTC by rwaldron comment:4

@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

Changed February 12, 2013 08:48PM UTC by BrianMinister@gmail.com comment:5

Thank you. Editing my blog accordingly.

I made wrong assumptions on how older scripts are running on newer version of the library.