Side navigation
#7499 closed enhancement (invalid)
Opened November 13, 2010 01:19PM UTC
Closed November 13, 2010 05:38PM UTC
data() can only read Data Attribute objects in single quotes
Reported by: | p_gasston@yahoo.com | 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.
Replying to [ticket:7499 p_gasston@…]:
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/).