Open mreis1 opened 9 years ago
After digging into the problem by starting a simple project to ensure that only essencial code was part of the content I realize that the problem report above is not, somehow, caused by my code.
I did this Demo where I achieved the desired task https://github.com/mreis1/jqmrouter-singlepage
Anyway during the development of that demo i detected another problem with deferred transitions. For example, If we click on link whose router handler is preventing the page transition for something like 2 seconds (just an example), If I click on second link during the those 2 seconds we'll face one of the following problems: a) if the second link takes lesser than 2 seconds to navigate to the target page we will be redirected to the second link and when the first link gets resolved, we are taken to it's content. b) if the second link takes longer than 2 seconds the problem will be the opposite. First we are taken to the first page and then right after to the second page
Probably the default desired behavior would be cancel any ongoing deferreds.
As specified at the documentation it's possible to preventDefault the $.mobile.pageChange() and resolve it as soon as we want.
So, because my application keeps most of it's UI structure in all diferent views, like header and sidebar, I decided to create the following approach.
at index.html
at router.js
the pageChanger monitors the last JQM page where html data referencing the view was appended. For example. if we appended data into "#page1 .placeholder" when transtioning to #page?id=dogs, if we change to #page?id=cats our target view will be #page2 (which is response from the pageChanger.getNextPage())
This solution is great because it solves the visual problem of transitioning to the same page where most of the time we see:
Any help please?