Comments on: Using jQuery’s Data APIs http://www.learningjquery.com/2011/09/using-jquerys-data-apis Tips, techniques, and tutorials for the jQuery JavaScript library Tue, 21 May 2013 00:41:32 +0000 hourly 1 http://wordpress.org/?v=3.5.1 By: Lorenzo http://www.learningjquery.com/2011/09/using-jquerys-data-apis/comment-page-1#comment-87452 Lorenzo Tue, 19 Feb 2013 23:50:25 +0000 http://www.learningjquery.com/?p=1346#comment-87452 html 5 data and JQ data are not the same as explain previously :

// Change the HTML5 data-* attribute
$('#poem').attr('data-poet', 'William Shakespeare');

console.log( $('#poem').data('poet') );
//>> "Edna St. Vincent Millay"

console.log( $('#poem').attr('data-poet') );
//>> "William Shakespeare"

]]>
By: Pawel http://www.learningjquery.com/2011/09/using-jquerys-data-apis/comment-page-1#comment-87385 Pawel Fri, 28 Dec 2012 14:02:29 +0000 http://www.learningjquery.com/?p=1346#comment-87385 Nice and simple explanation of Data APIs, I like it better than jQuery’s docs. Cheers!

]]>
By: eBuildy http://www.learningjquery.com/2011/09/using-jquerys-data-apis/comment-page-1#comment-87373 eBuildy Wed, 12 Dec 2012 16:29:52 +0000 http://www.learningjquery.com/?p=1346#comment-87373 Hmmm, I dont understand the complexity of src/data.js, why they don’t use attr methods instead ?

jQuery.data = function(key) { return jQuery.attr(‘data-’ + key); } works fine for me.

also, see this fiddle : http://jsfiddle.net/h7UZ9/1/ get data method is a bit buggy isnit ?

]]>
By: Karl Swedberg http://www.learningjquery.com/2011/09/using-jquerys-data-apis/comment-page-1#comment-87337 Karl Swedberg Tue, 06 Nov 2012 13:12:38 +0000 http://www.learningjquery.com/?p=1346#comment-87337 Hi Paul,

From the documentation: “When the data attribute is an object (starts with ‘{‘) or array (starts with ‘[‘) then jQuery.parseJSON is used to parse the string; it must follow valid JSON syntax including quoted property names.”

Valid JSON requires double quotes for property names and string values.

]]>
By: PaulKD http://www.learningjquery.com/2011/09/using-jquerys-data-apis/comment-page-1#comment-87336 PaulKD Tue, 06 Nov 2012 09:35:51 +0000 http://www.learningjquery.com/?p=1346#comment-87336 Is this a gotcha or have I not RTFM?

objects work –

<div id="novel" data-novelist='{"firstname": "Jose", "lastname": "Saramago"}'>Blindness</div>

objects undefined or appear as string

<div id="novel" data-novelist="{'firstname': 'Jose', 'lastname': 'Saramago'}">Blindness</div>

]]>
By: HoliBaCu http://www.learningjquery.com/2011/09/using-jquerys-data-apis/comment-page-1#comment-87278 HoliBaCu Sat, 15 Sep 2012 22:26:43 +0000 http://www.learningjquery.com/?p=1346#comment-87278 “data-caMEL-case” becomes “camelCase” in IE9 :
http://jsfiddle.net/XcD8m/15/

]]>
By: jQuery data API | TripluDubluV http://www.learningjquery.com/2011/09/using-jquerys-data-apis/comment-page-1#comment-86719 jQuery data API | TripluDubluV Mon, 14 May 2012 14:46:42 +0000 http://www.learningjquery.com/?p=1346#comment-86719 [...] Methvin, membru in jQuery Core Team, are un articol inedit pe LearningjQuery.com numit “Using jQuery’s Data API“. In articol este vorba despre ce vroia la inceput sa fie .data() API, un mod de stocare [...]

]]>
By: How to Use jQuery's data() Method | JavaScript Mountain http://www.learningjquery.com/2011/09/using-jquerys-data-apis/comment-page-1#comment-86525 How to Use jQuery's data() Method | JavaScript Mountain Mon, 06 Feb 2012 06:11:13 +0000 http://www.learningjquery.com/?p=1346#comment-86525 [...] http://www.learningjquery.com/2011/09/using-jquerys-data-apis [...]

]]>
By: Karl Swedberg http://www.learningjquery.com/2011/09/using-jquerys-data-apis/comment-page-1#comment-86066 Karl Swedberg Wed, 04 Jan 2012 13:16:31 +0000 http://www.learningjquery.com/?p=1346#comment-86066 Which script are you talking about?

]]>
By: VT http://www.learningjquery.com/2011/09/using-jquerys-data-apis/comment-page-1#comment-86053 VT Wed, 04 Jan 2012 10:15:57 +0000 http://www.learningjquery.com/?p=1346#comment-86053 This script is not working on iphone. can you please help.

]]>