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

Refreshing triggers router on jQm v1.1 but not v1.2 #64

Closed timwis closed 12 years ago

timwis commented 12 years ago

Hello and great work on this project!

Let me start by saying I've ready issue #42 and this doesn't seem to be related. Mine's much simpler.

Basically, the router works great when I start on page 1 of my application. But if I navigate to a second or third page and hit refresh, the parameters in the URL do nothing and it takes me back to the first page. It seems like the router isn't triggered at the initial load.

My router is as simple as this (a test case) var router = router || new $.mobile.Router({ "#two": { events: "bs", handler: function() { $("#result").text($("#one input").val()); } } });

To see what I mean, click these two links, type something in and hit search to go to page 2, then refresh. jQm v1.1 http://dev.timwis.com/test-1.1.html (works) jQm v1.2 http://dev.timwis.com/test-1.2.html (doesn't work)

Am I doing something wrong or is this a compatibility issue?

azicchetti commented 12 years ago

Hi, unfortunately this is a jQM bug. I've reported the issue and hopefully they'll fix it in the next point release.

https://github.com/jquery/jquery-mobile/issues/5085 https://github.com/jquery/jquery-mobile/issues/5080

It also seems that, starting from jQM 1.2.1, we'll have native support for hash parameters. The router will probably need to be rewritten in some parts to work with the upcoming jQM release, but hopefully this will mean increased stability.

Cheers, Andrea

timwis commented 12 years ago

Oh, wow - is there anything I can do in the meantime as a workaround or will I just have to keep using jQm v1.1? Also, thanks for your prompt response!

azicchetti commented 12 years ago

I think they fixed the issue on the git, you just have to download the latest branch.

As far as I can remember, the router needs a couple of patches to properly work with the upcoming jqm release. Hopefully I'll find some time this weekend to test and commit them into a new file dedicated to jqm 1.2.1 onward (there'll still be a legacy version for pre-1.2.1 releases).

azicchetti commented 12 years ago

The patch was quite easy but, with the latest jQM trunk, you can't bookmark urls with hash parameters anymore. As a consequence, it's pretty useless to develop or test dynamic applications against it.

I've addressed the issue here: https://github.com/jquery/jquery-mobile/issues/5230

As soon as they fix it (or provide us something to preserve parameters) I'll push the new release to the git.