Closed schvenk closed 13 years ago
A simple solution would also be encoding parameters into the url instead of (or in addition to) passing the referrer to the pagebeforeshow handler.
The typical approach we have to use with the current version of jQM is attaching handlers to anchors and updating internal application statuses, which is working fine, but the pages can't be reached through a straight link, they need some clicking by the user.
I we could build an anchor with the following href:
or mypage.html#param=value or mypage.html#?param=value (for ajax pages)
the handler would access the data by simply reading the current href and render the proper content dynamically. Unfortunately none of the url above currently works on jQM (#mypage?param=value is close but it's buggy).
This isn't strictly needed for a phonegap application, but making bookmarking possible opens up a lot of possibilities even for simple mobile websites, for instance rendering pages on the client using client-side templates (jquery-tmpl or frameworks such as knockoutjs).
I know that "normal" parameters (mypage.html?foo=bar) are supported but:
This behavior is now possible using the pagebeforechange event. There's some documentation you can view here: http://jquerymobile.com/test/docs/pages/page-dynamic.html
When a jQuery Mobile app exists purely client-side (for instance, for use with PhoneGap), there's no way to make a dynamic page whose content/behavior depend on how it was loaded.
For example: suppose I want to make a master/detail view. The detail is a single page DIV in the HTML whose content is loaded from a local database based on which master item was tapped. Right now this isn't possible: the asynchronous nature of JS events makes it impossible for the pageshow or pagebeforeshow event to get that information reliably. I suspect there are other use cases as well, in which generic information other than the referrer would be useful.
My proposal: (1) Always pass the referring element (i.e. whatever was tapped or otherwise cause the page switch) as a second argument of the pageshow or pagebeforeshow handler, and maybe other handlers as well. (2) Potentially go further by allowing the developer to customize that event-handling further. Not 100% sure how this would work...maybe allowing the addition of a tap handler that's guaranteed to fire before the pagebeforeshow event or something, or the ability to pass additional info via a data-info attribute on the tap target.
Honestly, (2) may not be necessary, but I think (1) is essential. I'm really liking jQuery Mobile! But to be honest until there's a solution for (1) I can't get my app to work with it.
Thanks!