Inconsistent :jqmData selector when using $.fn.jqmData() #4948

Closed
slusarz opened this Issue Sep 6, 2012 · 4 comments

Projects

None yet

4 participants

@slusarz

Data set via $.fn.jqmData() is not accessible via the :jqmData selector.

Example HTML:

<div id="base">
  <div id="element1" data-foo="1"></div>
  <div id="element2"></div>
</div>

Example JS code:

// [ div#element1 ] - correct behavior
$('#base').children(':jqmData(foo)');

// Set data-foo to 1 on the second element also
$('#element2').jqmData('foo', 1);

// [ div#element1 ] - incorrect behavior; I would expect this to return [ div#element1, div#element2 ]
$('#base').children(':jqmData(foo)');

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

@Golodhros

+1 to this

@simesime

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

@arschmitz
jQuery Foundation member

please see issue #6695 we will no longer have jqmData in any form after 1.5

@arschmitz
jQuery Foundation member

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

@arschmitz arschmitz closed this Nov 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment