Skip to main content

Bug Tracker

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.

Attachments (0)
Change History (2)

Changed November 13, 2010 03:51PM UTC by jitter comment:1

Replying to [ticket:7499 p_gasston@…]:

so the following should also be valid: <div data-example="{'foo':'bar'}">

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/).

Changed November 13, 2010 05:38PM UTC by dmethvin comment:2

resolution: → invalid
status: newclosed