I need to fire a plugin on certain trigger elements.
I’m using this:
$( ':jqmData(role="page"):jqmData(trig="true")' ).live( 'pagebeforeshow',function(e){
console.log("detected");
// stuff to do...
});
Since this is my background page (first one in the DOM), using live fires it on every transition and replacing live with one only fires it on the initial trigger element and not on the 2nd element being pulled in.
Question:
How can I set up a function that is “live to trigger elements, but runs only once per trigger element found”? Would setting a flag with data help?
Thanks for infos!
I guess your dilemma is that you have to use
.live(), since initially there is only 1 matching element in the DOM, rather than how they are ordered? Otherwise,.one()should work fine. The manual has a nice example for how you can implement.one()using.bind(), here is how you do it with.live(), it should do the trick: