Permalink
Browse files

Fixed the issue #48.

Support for form submission was added in order to handle GET parameters
  • Loading branch information...
azicchetti committed Sep 3, 2012
1 parent c12bb13 commit f92a6f959ffe8d5092eb14be9481c6f3e979d5ae
Showing with 29 additions and 8 deletions.
  1. +11 −0 README.md
  2. +8 −3 js/jquery.mobile.router-dev.js
  3. +8 −3 js/jquery.mobile.router.js
  4. +2 −2 js/jquery.mobile.router.min.js
View
@@ -28,6 +28,7 @@ In addition, if you want to use standard hashchange-based routers, you have to d
What's new in the latest versions
=====================
+* Form parameters are now correctly handled
* support for pagebeforechange, pagebeforeload, pageload
* Added a parameter in the configuration object to execute only the first route handler found
* Support for a different syntax defining your routes
@@ -327,12 +328,22 @@ This ensures that even the first pageinit event can be catched and handled by th
* please make sure that the router is not instantiated multiple times by mistake. This will lead to
routes being fired twice, at least
+* do not assign id's to page divs, unless you're using a single-file multipage template. In fact,
+ids will interfere with data-url generation (at jquery mobile level) in ajax applications
+
* do not call $.mobile.changePage during a page transition with the destination page being the one
the framework is already transitioning to.
That is to say, if you click on a link to #foo and you have a pagebeforeshow route bound to it,
DO NOT invoke $.mobile.changePage("#foo") in your handler (the result will be an epic failure due to
a bug in jquery mobile)
+* pay attention to the ORDER in which events are fired. Remember that pagebeforeshow is fired *before*
+pagebeforehide, so if you're cleaning the dom when the page is being hidden and do your rendering stuff
+in pagebeforeshow, you have to be careful during same-page transitions or you'll get a blank page.
+You can use a certain counter (incremented during *show events and decremented during the hiding) and
+clean the dom only when it's 0, or examine window.location, or (better) use the "ui" argument passed to
+the handler (.nextPage is the property that you need)
+
* DOUBLE CHECK your REGULAR EXPRESSIONS! A typical mistake is forgetting the $ operator.
If you have two pages, such as #product and #productList, a hypothetical route "#product" would
match both pages, leading to unexpected behaviors. Use the $ operator when unsure: "#product$"
@@ -1,5 +1,5 @@
/*!
- * jQueryMobile-router v0.9
+ * jQueryMobile-router v0.93
* http://github.com/azicchetti/jquerymobile-router
*
* Copyright 2011 (c) Andrea Zicchetti
@@ -48,12 +48,17 @@ $(document).bind("mobileinit",function(){
if ( data.options.hasOwnProperty("_jqmrouter_handled") ){ return; }
data.options._jqmrouter_handled = true;
-
+ // handle form submissions
+ if (data.options.data && (data.options.type+"").toLowerCase()=="get"){
+ toPage+="?"+data.options.data;
+ }
var u = $.mobile.path.parseUrl( toPage );
previousUrl=nextUrl;
nextUrl=u;
- if ( u.hash.indexOf("?") !== -1 ) {
+ if ( u.hash.indexOf("?") !== -1 ||
+ (u.hash.length>0 && previousUrl!==null && previousUrl.hash.indexOf(u.hash+"?")!==-1)
+ ) {
var page=u.hash.replace( /\?.*$/, "" );
// We don't want the data-url of the page we just modified
// to be the url that shows up in the browser's location field,
View
@@ -1,5 +1,5 @@
/*!
- * jQueryMobile-router v0.9
+ * jQueryMobile-router v0.93
* http://github.com/azicchetti/jquerymobile-router
*
* Copyright 2011 (c) Andrea Zicchetti
@@ -48,12 +48,17 @@ $(document).bind("mobileinit",function(){
if ( data.options.hasOwnProperty("_jqmrouter_handled") ){ return; }
data.options._jqmrouter_handled = true;
-
+ // handle form submissions
+ if (data.options.data && (data.options.type+"").toLowerCase()=="get"){
+ toPage+="?"+data.options.data;
+ }
var u = $.mobile.path.parseUrl( toPage );
previousUrl=nextUrl;
nextUrl=u;
- if ( u.hash.indexOf("?") !== -1 ) {
+ if ( u.hash.indexOf("?") !== -1 ||
+ (u.hash.length>0 && previousUrl!==null && previousUrl.hash.indexOf(u.hash+"?")!==-1)
+ ) {
var page=u.hash.replace( /\?.*$/, "" );
// We don't want the data-url of the page we just modified
// to be the url that shows up in the browser's location field,

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit f92a6f9

Please sign in to comment.