opitzconsulting / jquery-mobile-angular-adapter

jquery mobile angular adapter
MIT License
517 stars 114 forks source link

Routing fails when navigating again directly after a navigate('back') #84

Closed mlegenhausen closed 11 years ago

mlegenhausen commented 11 years ago

Following fiddle illustrates the problem: http://jsfiddle.net/LRqp5/4/

Following steps:

  1. On #main -> $navigate('#main1');
  2. On '#main1' -> $navigate('#main2', 'someFunction');
  3. $scope.someFunction = function() { $navigate('#main') };

What happens is that after the someFunction call I get another navigate to '#main2'.

mlegenhausen commented 11 years ago

I found a solution by replacing the backMode method with the following:

$location.backMode = function () {
                $location.replace();
                return this;
            };

Maybe you can validate if this is a valid solution?

tbosch commented 11 years ago

Sorry, but this will only allow to go back 1 step in history. But $location.backMode is made to go back multiple steps. Your workaround will remove this functionality...

Tobias

tbosch commented 11 years ago

Hi, as far as I can see, the example works well now: Clicking on the next buttons navigates forwards. Clicking on the "back" button on the last page first navigates one step back to page "main1" and calls the function "previous", as specified in the call to $navigate("back", "previous"). As the function previous on page1 does another navigate to page main, we see another navigation and end up in total on page main.

Could you check if this is the desired behavior?

Tobias

mlegenhausen commented 11 years ago

Looks good :) I will test it in our app and give you feedback. Thanks again :)

mlegenhausen commented 11 years ago

Solved.