azicchetti / jquerymobile-router

A router/controller for jquery mobile. Also adds support for client-side parameters in the hash part of the url. The routes handles regexp based routes. This plugin can be used alone or (better) with Backbone.js or Spine.js, because it's originally meant to replace their router with something integrated with jQM.
GNU General Public License v2.0
402 stars 69 forks source link

doesn't really work jqm1.2.0 rtm #63

Open dotnetwise opened 12 years ago

dotnetwise commented 12 years ago

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!

ghost commented 12 years ago

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!

azicchetti commented 12 years ago

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.

cdiaz-concur commented 12 years ago

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!

cdiaz-concur commented 12 years ago

It looks like this may be an issue with jQM 1.2.0 rather than router:

https://github.com/jquery/jquery-mobile/commit/207f854733ebdd684e2f7fea44201621cd91bc08 https://github.com/jquery/jquery-mobile/issues/5121 https://github.com/jquery/jquery-mobile/issues/5085

azicchetti commented 12 years ago

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 (https://github.com/jquery/jquery-mobile/issues/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.

cdiaz-concur commented 12 years ago

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! =)

rmgdc commented 12 years ago

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.

joelstein commented 11 years ago

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

rmgdc commented 11 years ago

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)