Data set via $.fn.jqmData() is not accessible via the :jqmData selector.
<div id="element1" data-foo="1"></div>
Example JS code:
// [ div#element1 ] - correct behavior
// Set data-foo to 1 on the second element also
// [ div#element1 ] - incorrect behavior; I would expect this to return [ div#element1, div#element2 ]
The return from this selector should not be dependent on whether someone manually entered the data in an HTML attribute. At a minimum, this is not documented. At worst, this is undesirable behavior.
It would seem the easiest way to fix would be to add the HTML attribute automatically within $.fn.jqmData().
+1 to this
I also find this annoying, http://jsfiddle.net/r8KPu/ is a simple reproduction of the error, which in my case is worked around by using a loop. Any comments on this? I'm using jQuery 1.9.1 and jQm 1.3.2
please see issue #6695 we will no longer have jqmData in any form after 1.5
also the selector is for selecting elements that have data attributes and use jqm name spacing the jqmData function is for setting and getting data on elements not data-attributes. please see documentation for .data http://api.jquery.com/data/ this is just a namespaced version closing this as not a bug