I am attaching a click event to an image on my page.
$('.ui-block-b img').click(function(event) {}
I am using a jQuery mobile fixed footer.
I have tried to initialize this using both the pagecreate
and pageinit
event.
When I click on the links (being loaded with Ajax) in the footer and then come back to the page with the click handler the pagecreate
and pageinit
are being refired. This is attaching another click event, so when I click on the image 2 events are being fired.
I am wondering is there a jquery Mobile event that address this?? Did i miss something in the documentation?
I have addressed this problem by checking if the event exists before attaching it but it seems like jQuery mobile should have something to that handles this? I have done
var events = $('.ui-block-b img').data('events');
if (typeof events == 'undefined') { // attach handler}
Perhaps jQuery mobile already addressed this issue and I'm just missing something?