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

pagebeforechange doesn't work with JQM 1.1.1 #53

Open joanscript opened 11 years ago

joanscript commented 11 years ago

That is, the router doesn't work with the new version of the jQuery Mobile. Could u please have a look on this issue? Thanks

azicchetti commented 11 years ago

Hi, I've not yet tested it extensively (I'm quite busy atm), but it seems to work as expected, at least for the most basic test cases under the examples/ directory (jquery mobile 1.1.1, jquery 1.7.1).

Please provide some code if you find that something is off. Thank you!

joanscript commented 11 years ago

For example, u can test the /test-bC.html. If u are on #localpage4 page and reload it, the index appears.

azicchetti commented 11 years ago

Uh, the pagebeforechange event...

For that specific test-case, it seems a jquery mobile bug to me but I've not yet debugged anything.

However, I wouldn't recommend using that event from the router because it breaks other useful routes and somehow conflicts with the router itself.

If you need to inject pages into the dom by hand, switch to a "fake" ajax approach, disable pushState and use the pagebeforeload event.

In case this approach is not of your liking, I suggest you attach a pagebeforechange handler before the router javascript file is loaded and take things over from that point.

joanscript commented 11 years ago

I see what u mean, but for example if I do your last point, which seems quite ok, I might not need the plugin, don't u think? Anyway, and as u commeneted , after doing some more tests with the pagebeforechange event, it might be a jquery mobile problem!

azicchetti commented 11 years ago

Il 13/07/2012 16:23, joanscript ha scritto:

I see what u mean, but for example if I do your last point, which seems quite ok, I might not need the plugin, don't u think?

Yeah, it would probably be less useful but still usable for certain events (pagebeforeshow, pagehide, etc).

I usually use the first approach for complex applications, it also keeps the dom small due to the automatic page removal mechanism of jquery mobile. It can be mixed with a certain number of local "hash pages" that should be kept in the dom right from the beginning.