Comments (14)
Hi raldred,
thanks for digging into this problem.
As far as I can remember, even 1.0.1 triggers pagebeforechange twice and the router tries to discard the second call by using the property _jqmrouter_handled [in previous versions I was using a different approach that wasn't supporting explicit $.mobile.changePage's with a jquery object as the first argument].
I've done a couple of experiments (jquery 1.7.1 and jqm rc1) and everything seems consistent to me with the previous 1.0.1 version, so I'm probably missing something important (for instance, I haven't tried a programmatic $.mobile.changePage).
Would you mind sharing your example?
Thank you
from jquerymobile-router.
Hi Andrea, thanks for getting back to me about this.
I've prepared a couple of examples, the same except the version of jqm, both using the current master of mobile router.
To replicate..
Click "Section 1"
Click "Chunk 1"
Click "Back"
In the 1.1.0 RC1 example clicking "Back" will cause the #section page to transition twice.
1.1.0 RC1
http://jsfiddle.net/robaldred/BJvHf/
1.0.1
http://jsfiddle.net/robaldred/ufnGy/
(Tested with Chrome Mac 17.0.963.65)
from jquerymobile-router.
A quick followup until I have more time to dig into the problem.
It seems that the 1.1.0 version will support parameters in the hash part of the url natively (this is very good news!) and so the
if ( u.hash.indexOf("?") !== -1 ) {
...
}
branch in the router is no longer needed.
Removing it apparently fixes the problem.
It would be great if you had a little time to confirm it.
Thanks!
from jquerymobile-router.
Hi again,
Interesting, that is pretty good news.
I've altered the router to remove the addon support for parameters.
the pagebeforechange now looks like....
$(document).bind("pagebeforechange", function( e, data ) {
var toPage=( typeof data.toPage === "string" ) ? data.toPage : data.toPage.jqmData("url")||"";
if ( data.options.hasOwnProperty("_jqmrouter_handled") ){ return; }
data.options._jqmrouter_handled = true;
var u = $.mobile.path.parseUrl( toPage );
previousUrl=nextUrl;
nextUrl=u;
$.mobile.changePage(toPage, data.options);
e.preventDefault();
});
It seems to work correctly, however I might need to do some further testing.
from jquerymobile-router.
Uhm, try deleting the last two lines (I think the problem here was the changePage. Basically, that part of the router code is now in jquery mobile itself, so we need to remove it to avoid duplicates)
$.mobile.changePage(toPage, data.options);
e.preventDefault();
from jquerymobile-router.
great stuff, that works aswell.
So i literally just have
$(document).bind("pagebeforechange", function( e, data ) {
var toPage=( typeof data.toPage === "string" ) ? data.toPage : data.toPage.jqmData("url")||"";
if ( data.options.hasOwnProperty("_jqmrouter_handled") ){ return; }
data.options._jqmrouter_handled = true;
var u = $.mobile.path.parseUrl( toPage );
previousUrl=nextUrl;
nextUrl=u;
});
from jquerymobile-router.
yep, that should be it!
I'm taking a few days to properly examine jquery mobile sources before pushing a patch, so please use your own version in the meanwhile.
from jquerymobile-router.
Sure thing, thanks for your help, really appreciate your work on the plugin, it's been a great addition to my app.
from jquerymobile-router.
Hey, just found an issue with the modifications we made.
We need the following 3 lines back in:
data.options.dataUrl = u.href;
$.mobile.changePage(toPage, data.options);
e.preventDefault();
Without these browsing to and from the same path with different params does not change the browser hash or the jquery history to reflect the new params.
from jquerymobile-router.
You mean browsing from #page?foo=bar to #page?bar=foo ?
If we put back those lines we may have problems with ajax pages, actually I guess it would break them completely.
I think that with a simple check on the active page we may fix this bug without too much effort, but it would be better if it was fixed in jquery mobile itself, since it seems a problem in their newly added code to support parameters in the hash.
Do you mind making a super-simple test page without the router and submit the bug report (if it still applies!) to jquery mobile guys?
If they won't fix it, I'll hopefully make a patch before the final 1.1.0 is released
from jquerymobile-router.
Ahh damn, it also breaks dialogs. I'll try but im not entirely sure what the issue with jqm's internals are, dont suppose you could point me to the section youve been looking at?
from jquerymobile-router.
Ok, dirty, but for the time being this works for my particular application (Dialogs & Ajax pages also work fine).
Also, im using the jqm simpledialog2 plugin which works aswell now.
if(u.href != "") {
data.options.dataUrl = u.href;
$.mobile.changePage(toPage, data.options);
e.preventDefault();
}
from jquerymobile-router.
I'm supposing that the problem we're talking about is browsing from #page?foo=bar to #page?bar=foo, is it correct?
I think the problem with jqm is that they've added support for hash parameters in the url but they forgot to enable same page transitions.
Try replacing your #section page with this one:
<div id="section" data-role="page" data-add-back-btn="true">
<div data-role="header"><h1>Section</h1></div>
<div data-role="content">
<ul data-role="listview">
<li><a href="#section?id=2">Same page id=2</a></li>
<li><a href="#section?id=3">Same page id=3</a></li>
<li><a href="#section?id=4">Same page id=4</a></li>
</ul>
</div>
</div>
Don't load the jqm router.
You'll notice that clicking any of the "same page" links won't do anything (this is the jqm bug, I suppose).
Now, try loading the original jqm-router version (the unpatched one). Links are now working as expected.
jQuery mobile should handle this scenario natively
from jquerymobile-router.
Hi,
I've pushed a fix to support jqm 1.1.0rc2.
It turns out that the 'native' support for hash parameters is a side effect of a jquery selector used in the loadPage() function of jQM.
Since I'm scared by this, I'm keeping the code we removed a couple of weeks ago in the router, because it feels more safe and sound.
Hopefully the handler won't be called twice with the latest fix.
from jquerymobile-router.
Related Issues (20)
- Not an issue actually but the request to provide more advanced example HOT 3
- jQM 1.3.0 HOT 8
- Examples don't work HOT 2
- default handler not called HOT 3
- Routing issues with JQM 1.3.1 and knockout.js HOT 3
- Early Router - Too late for first page? HOT 2
- Debugging snippet gets in the way HOT 4
- URI parameters are striped out when using new pagebeforechange event HOT 4
- Loading the first page via bc handler HOT 6
- handler getting called twice even when step "url" selected HOT 1
- With requireJs, router initialises after jQuery Mobile page events trigger HOT 2
- How does one access the data object resultant from a $.mobile.navigate('#target',{}) invocation HOT 1
- production ready? HOT 1
- e.preventDefault() on a re-routing system HOT 1
- Are urls like this "#category/:id/items" possible? HOT 1
- Can this be used using two different html files? HOT 4
- Back Problem HOT 2
- Bower support HOT 1
- defaultHandler is not invoked when customer handlers are not specified
- Am I right that this plugin doesnt work in jqmobile 1.4.5 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquerymobile-router.