jquery/jquery-mobile — Issue #2742: Opening pages during document loading doesn't update history
Author: yunosh
Created: 2011-10-18 19:27:08+00:00
State: open

kinblas and I were trying to figure out on IRC why opening a dialog page from a pagechange event handler for the initial page of a document opens the dialog just fine, but closing it returns two steps back in the history. We figured that browsers probably don't update history as long as the initial event loop is running, thus the history is not setup correctly if opening the dialog from early running event handlers. Using setTimeout(..., 0) to open the dialog works just fine. This is some reduced pseudo code:

var showNotifications: function(msg) {
$.mobile.changePage($('#notification'), { transition: 'pop' });
}
$("body").live("pagechange", function(e) {
$(document).unbind("pagechange", myfunc);
showNotifications('hello world');
});