As some background, I have a jQuery Mobile app where each url is fully loadable as jquery html pages, but they also have the capacity to return a json response instead.
Is there any way to tap into jQuery Mobile's url changing functionality without actually transitioning to a new page? I know that isn't a very jQuery Mobile-ish thing to do, but jQuery Mobile has really nice cross-browser url changing behavior, and there are a couple places where I would like to load some content, change the url, but not actually change the page (particularly since the app behaves like a single page app overall, so there are times where there is a ton of redundancy in reloading the entire page).
I know about #changePage() and #loadPage(), but change page is a full page change (not what I want) and #loadPage doesn't change the url (plus, i'm looking for a slimmer json response in these cases, and loadPage is gonna load the whole html payload and inject it into the DOM).
And using ajax would allow me to interface with the server, but it doesn't update the navigation bar, which is my goal. jQuery Mobile has alot of functionality around handling cross-browser functionality changing the navigation bar and keeping track of history. I want to tap into that without actually changing the jQuery Mobile page.
Between these and the extensive set of DOM-manipulation functions, I think it is everything you need.
Aside from that, you will need to learn how to refresh the various jQuery Mobile widgets. It's kind of messy, as there isn't much consistency between widgets as to how you signal them that you've added or updated something.
watusiware, I appreciate the quick responses! but I think you're missing what I'm getting at.
I am already using plenty of manual ajax and I am dynamically refreshing jquerymobile widgets throughout my app (and am well aware of the inconsistencies you speak of, particularly around popups :D).
The goal I am trying to achieve, is to in some cases refresh manually using my own ajax calls, but still actually change the browser navigation url. jQueryMobile has internal functionality for handling navigation changes. Their functionality is built around handling multiple browsers and devices, and I wanted to tap into that.
During our mismatched responses, I decided to dig a bit deeper into their internals (I've done a fair bit of debugging of the src) and I'm now wondering if $.mobile.urlHistory might allow me to do this. I'll take a look at that.
For me, I see jQuery Mobile as having some great virtues, but trying to do too much in one place. I see a widget framework, router, and interaction layer all wrapped into a tightly coupled package. I really want aspects of the widgets + interactions, but I want to manage some of the routing myself. I am trying to see if I can pull some of that out today (and hope that some of it gets more split out in the future).
urlHistory looks like no help, it seems to mostly be for managing where we came from and where we're going but not actually doing it for us.
Seems like maybe the onHashChange method is the place that really does the work with the history.replaceState method. Just was interested if any part of the jqmobile api exposed an ability to change the browsers url without going through the full page change process.
The API doesn't fully describe what is available in the jqm1.3 beta, but the actual code contains ways of suppressing the hashchange listening that jquerymobile normally performs so that you can manipulate things with JSON without actual changing the page (and still become part of the jquerymobile history + change the browser url).
Leave a comment on jpcamara's reply
Change topic type
Link this topic
Provide the permalink of a topic that is related to this topic