Currently, I am working on developing a jQuery Mobile and PhoneGap application. Here is an excerpt of the code I am using:
$('#contact').live('pageinit', function() {
//$.mobile.loading('show');
theme();
getData('contact/list', contactList);
//$.mobile.loading('hide');
});
Everything seems to work fine when accessing the page for the first time. However, upon subsequent attempts, the event starts firing multiple times. I have attempted using bind
but it did not resolve the issue.
I suspect this behavior is related to the live
event being bound each time the page is initialized, leading to multiple firings. I found that linking through window.location.href
resolves the problem as it recreates the DOM, although unfortunately, this solution is not feasible in my case.
Is there an alternative approach to handling the pageinit
event?
I have tried searching for a solution without success thus far. I also came across a similar issue discussed on: click() firing multiple times.