azicchetti/jquerymobile-router

doesn't really work jqm1.2.0 rtm

dotnetwise opened this issue · 9 comments

Unfortunately it doesn't work to jqm 1.2.0
Update your examples to use it and you'll see what I'm talking about!

I have a quite large project and upgraded to jQM 1.2.0 and there are no problems with the router, except issue#61, which was related to the new popup widget.

However, Andrea fixed it immediately.

If you have some issues I suggest being more specific!

Hi @dotnetwise,
as bardu said I can't be of much help until I see your code.

Basic test cases with 1.2.0 seem to work as expected (ajax and local pages with standard page events), although I'm sure that under obscure circumstances certain things may fail.

I am experiencing the same problem as dotnetwise.

To replicate, modify examples/test.html to use the new jQM 1.2.0 along with jQuery 1.8.2. Clear all browser cache and exit out of all browser tabs and windows - basically launch a fresh browser.

Instead of launching the test example normally, try going to localpage2 with parameters.

e.g. http://localhost/router/examples/test.html#localpage2?foo=bar

Notice the JS console will output "Index has been show" instead of the expected "localpage2: pagebeforecreate #localpage2?foo=bar".

Now, try launching the same localpage2 URL but without any parameters. You can see from the output in the JS console that the correct handler was triggered.

It seems the issue arrises when you are trying to launch a page with parameters (rather than from a link within the jQM app). This is a major road-block for my app since I'm launching into my jQM app from within my native Android app and it fails.

Any help would be greatly appreciated!

Hi @cdiaz-concur,
your last message describes the problem very well, so that I can at least point you in the right direction.

This issue has already been reported and analyzed (#64), but unfortunately it cannot be fixed on my end, because it's due to a bug in jQuery Mobile.
Basically, the first event is not triggered by the framework and the router cannot add support for hash parameters.

I've reported this to the jQM guys and they fixed it in the latest trunk.
Starting from 1.2.1, we'll have native support for hash parameters and this is a very good news, since I can strip that part from the router and improve its stability.

There's still another bug in the current jQM trunk that compromises the bookmarkability of urls, I'm waiting for them to fix it (jquery-archive/jquery-mobile#5230) before rolling out the next version of the router.

To sum this up, you have to wait for 1.2.1 or use the legacy version in the meanwhile.

Thanks for the quick response, azicchetti!

Good to hear this will be resolved in jQM 1.2.1. You and the jQM team are doing an awesome job! =)

If it can help somebody i've found a combination that allows to use jQM 1.2.0 and the router.

Using pushStateEnabled = true (mandatory for back buttons to work) and altering the router "pagebeforechange" event to:

if (data.options.fromHashChange) {
var toPage=location.hash;
} else {
var toPage=( typeof data.toPage === "string" ) ? data.toPage : data.toPage.jqmData("url")||"";
}

will do the trick.

Regards.
Azicchetti, thanks for the good work.

rmgdc, will you post an example of the code you got to work?

I've posted above. The trick is to alter the pagebeforeshow binding on mobile router to what i've posted. The pushStateEnabled is not needed (I had problems on some mobile browsers with pushStateEnabled = true)