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

changePage problem. #34

Closed rendom closed 12 years ago

rendom commented 12 years ago

Hi im testing out this plugin and i really like it. But i just notice one problem, i think i have misunderstood something but i hope someone can help me out here :).

I run jQuery.mobile.changePage( "address.html?id="+String(data), { transition: "slide"} ); and its working fine but my handler dosent get trigged.

My router var router=new $.mobile.Router({ "/address.html(?:?)?": {handler: "address", events: "s"}, },{ address: function(type, match, ui) { alert("hej"); } });

azicchetti commented 12 years ago

Hi, I'm glad you find it useful ;)

I guess the problem is the regexp, since it starts with "/". Can you try

 $.mobile.changePage("./address.html?id="... etc?)

to see if it solves the problem?

Cheers

rendom commented 12 years ago

Hm github destroyed the regex, check here insted http://cl.ly/3h1y391S0F1p1Z2E1T3q I tested to run this jQuery.mobile.changePage( "address.html", { transition: "slide"} ); but i get the same result, the page changes correct but no alert.

azicchetti commented 12 years ago

The regexp is fine, try changing the .changePage line to:

jQuery.mobile.changePage( "./address.html", { transition: "slide"} );

Prefixing the page name with "./" ensures that the regexp will always match.

rendom commented 12 years ago

Yeh i just notice that my page dosent got loaded correctly :) Thanks for the help and support :), back to developing my "app" ;).