Opened 12 years ago
Closed 12 years ago
#7499 closed enhancement (invalid)
data() can only read Data Attribute objects in single quotes
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | 1.5 |
Component: | unfiled | Version: | 1.4.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
When using data() to get objects from a Data Attribute, the attribute must be within single quotes:
<div data-example='{"foo":"bar"}'>
It's much more common to use double quotes for attributes, so the following should also be valid:
<div data-example="{'foo':'bar'}">
This is not currently recognized by jQuery.
Change History (2)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
Replying to [email protected]…:
This isn't a jQuery bug. The reason this doesn't work is the value of
data-example
looks like JSON but actually is invalid. JSON requires you to use double quotes (check http://www.json.org/).