I’m still not sure what causes the jQuery .data() function to fail.
EDIT: See edits below.
So when it does fail, I have switched to using .attr(). Yes, you can put “data-something” into your .attr() function call.
I hope to post more information on why .data() function fails. See below
Also note, if the :data selector fails, you can use element[data-something=”somedata”] to get around the issue.
Note: Schema doesn’t change using .data(). and if your call failed to get data then you get ‘Undefined’ object. Sucky object to get.
So now, when I am posting to, or reading from, data- from script, I use .data(), but when reading from data- which was supplied by the browser, I generally use .attr();
I’m not promoting cheating, I just want you to have options.
I went to someone else’ site, who was also talking about .data().
Their example was using jsFiddle, and without messing with the code, just a plain execute, same exact problem. http://blog.mitemitreski.com/2012/06/html-5-data-attributes-how-to-use-it.html
Mite, I think I need to give you a call about the same problem I am seeing. ;)
Note: I know .data() used to work, so I’m not sure what broke it.
I was corrected twice on this.
Changing a lot of code to accomodate this fix.