jquery/jquery-mobile — Issue #2927: Page init events firing multiple times on cached pages in Chrome
Author: anpsince83
Created: 2011-11-04 01:22:04+00:00
State: open

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.