Page init events firing multiple times on cached pages in Chrome #2927

Closed
anpsince83 opened this Issue Nov 4, 2011 · 7 comments

Projects

None yet

5 participants

@anpsince83

Page init events (pagebeforecreate, pagecreate, pageinit) are firing multiple times for cached pages (data-dom-cache="true" or set globally $.mobile.page.prototype.options.domCache = true; in Chrome.

If you navigate to a second page its page init events will fire as expected and the page is now cached in the DOM. Navigate back to the first page, and then navigate to the second page again, and its page init events will fire again. The weird thing is that if you navigate away from page 2, simply go back for example, the page 2 init events will fire again as you leave the page, and page 1's init events will fire again.

Another weird thing is it seems the events don't seem to be fired on the actual page that is the DOM. I set up a demo here: http://www.injuryfree.com/test/jqm/page1.html. Using the pagecreate callback I add some content to the page, as well as logging to the console everytime all of the pageinit events are fired. The second time the pageinit events fire, they log to the console, but the content is not added to the page. Weird.

I've tested in FireFox, Chrome, Safari and Mobile Safari on iPad2, and it only seems to occur in Chrome. Not sure about IE or any other browsers mobile or desktop.

@toddparker
Contributor

Thanks for reporting, we'll take a look!

@anpsince83

Not sure if I should open a separate issue for this, but it certainly seems related. I've noticed that if you register an event on an element inside of a dialog that closes the dialog (say an Okay button), that event fires twice in Chrome similar to the page init events.

@jasonlcrane
Contributor

This test case demonstrates the same problem in Chrome on a click event. http://jsbin.com/ubuyeg/19.

I can't reproduce in other desktop browsers either, or in Android 2.3. Mobile console output can be seen using http://jsconsole.com

@johnbender johnbender was assigned Dec 14, 2011
@redaemn
Contributor
redaemn commented Dec 20, 2011

Is this bug still present?!? I cannot reproduce it using your test pages... or maybe I didn't understand what the problem was... :(

@jasonlcrane
Contributor

I can no longer reproduce it in Chrome 16+ (16, as of last week, is the stable release). I can still reproduce it in Chrome 15.

Made a small change to the test page in case it's still necessary: http://jsbin.com/ubuyeg/20.

@anpsince83

@redaemn @jasonlcrane

I can no longer reproduce these issues either. I even switched the source back to RC2, which was current when I first reported the issue, and I could not reproduce it with that either. So this must have been an issue with Chrome.

@toddparker
Contributor

Alright, thanks guys. I'm going to close this one then, but we can re-open if you find a test case.

@toddparker toddparker closed this Dec 20, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment