1

Javascript woes today... I'm struggleing to get a selector right.

I need to select elements, that don't have jqmData(bound) === true in a jQuery chained statement. This is what I have:

var swipesOnPage = $('div.photoswipeable');
...
swipesOnPage.not(':jqmData(bound="true")')
            .jqmData('bound', true )
            .each( function(){
                // do stuff
            });

I need to flag lables that received their "treatment" so I'm not re-running code on them. However I cannot get the selector right, so all elements, which I have set jqmData("bound",true) get re-selected every time.

Question:
How to use the not or filter statement correctly with data-attribute?

Thanks!

frequent
  • 27,643
  • 59
  • 181
  • 333

1 Answers1

4
var $someCollection = $('div.photoswipeable').filter(function() {
    return $(this).jqmData("bound") !== true;
});
frequent
  • 27,643
  • 59
  • 181
  • 333
Andreas Louv
  • 46,145
  • 13
  • 104
  • 123