jquerymobile-router icon indicating copy to clipboard operation
jquerymobile-router copied to clipboard

pagebeforechange doesn't work with JQM 1.1.1

Open joanscript opened this issue 12 years ago • 5 comments

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

joanscript avatar Jul 13 '12 09:07 joanscript

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!

azicchetti avatar Jul 13 '12 09:07 azicchetti

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

joanscript avatar Jul 13 '12 11:07 joanscript

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.

azicchetti avatar Jul 13 '12 13:07 azicchetti

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!

joanscript avatar Jul 13 '12 14:07 joanscript

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.

azicchetti avatar Jul 13 '12 14:07 azicchetti