Trouble with $.mobile.changePage
in jQuery Mobile
•
11 years ago
I'm having a bit of trouble getting $.mobile.changePage working the jQM URL hash history. The history doesn't seem to be updating. As a result, when someone hits the back button (in the header or in the native browser) it navigates away to a previously visited site.
What I'm trying to do is intercept links on the page, build some UI client-side, and then invoke $.mobile.changePage to update the UI to the new screen. I'm doing this with a basic pattern like this:
$('a#my-test-link').live("click", function(evt) {
// build #woot here and insert into DOM...
$.mobile.changePage($("#woot"), "slide");
// prevent the normal click here
evt.preventDefault();
});
This works fine except for the history piece. I'm curious, does $.mobile.changePage not automatically update the history? I'd be surprised because it is adding a "back" button in the header automatically.
If it doesn't, how can I add an item to the history?
Is there a better way to perform this type of pattern without resorting to the default jQM Ajax pattern of requesting HTML from the server?
Thanks,
Stephen
7