#13440 closed bug (duplicate)
.data() is inconsistant when reading from data- attributes
Reported by: | 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 10 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
comment:2 Changed 10 years ago by
Resolution: | notabug |
---|---|
Status: | closed → reopened |
comment:3 Changed 10 years ago by
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
Duplicate of #13130.
comment:4 Changed 10 years ago by
@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 10 years ago by
Thank you. Editing my blog accordingly. I made wrong assumptions on how older scripts are running on newer version of the library.
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