locked
MVC SPA browser navigation buttorns RRS feed

  • Question

  • User-1350516731 posted

    Hello!

    In the single-page application is not working these buttons (next/back), manual modification history does not help browser. I stumbled on the Internet on a solution using anchors #. Can you tell us more details and step by step how to use it? For example, routes processed manually. Please, provide basic examples.

    Thank you.

    Monday, April 4, 2016 10:20 AM

Answers

  • User61956409 posted

    Hi Alex,

    In the single-page application is not working these buttons (next/back), manual modification history does not help browser. I stumbled on the Internet on a solution using anchors #. Can you tell us more details and step by step how to use it?

    This blog explained about “Fixing the Back Button: A Simple SPA Behavior using Location Hash”, you could check it.

    http://blog.falafel.com/fixing-back-button-simple-spa-behavior-using-location-hash/

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 5, 2016 5:25 AM
  • User-1926401737 posted

    hi,

    This article explained pushState and Single-Page apps, you could check it.

    http://www.frontendjournal.com/html5-pushstate-and-single-page-apps/

    with regards,

    swing

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 13, 2016 8:40 AM
  • User-474980206 posted

    this is normally managed by the routing framework you pick. there are dozens of these. here are some simple ones:

      https://www.npmjs.com/package/routes-js
      https://github.com/tildeio/router.js/
      http://millermedeiros.github.io/crossroads.js/

     many more are available. just google "javascript routing library"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 8, 2016 3:25 PM
  • User-129908252 posted
    app.run(function($rootScope, $location) {
        $rootScope.$on('$locationChangeSuccess', function() {
            if($rootScope.previousLocation == $location.path()) {
                console.log("Back Button Pressed");
            }
            $rootScope.previousLocation = $rootScope.actualLocation;
            $rootScope.actualLocation = $location.path();
        });
    });

    This will also trigger if the user clicks the Forward button or if they navigate to the last page they were on,
    rather than clicking the back button
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 22, 2016 1:15 PM

All replies

  • User61956409 posted

    Hi Alex,

    In the single-page application is not working these buttons (next/back), manual modification history does not help browser. I stumbled on the Internet on a solution using anchors #. Can you tell us more details and step by step how to use it?

    This blog explained about “Fixing the Back Button: A Simple SPA Behavior using Location Hash”, you could check it.

    http://blog.falafel.com/fixing-back-button-simple-spa-behavior-using-location-hash/

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 5, 2016 5:25 AM
  • User-1350516731 posted

    Thank you. Is there any other way?

    Tuesday, April 5, 2016 7:24 AM
  • User-1926401737 posted

    hi,

    This article explained pushState and Single-Page apps, you could check it.

    http://www.frontendjournal.com/html5-pushstate-and-single-page-apps/

    with regards,

    swing

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 13, 2016 8:40 AM
  • User-474980206 posted

    this is normally managed by the routing framework you pick. there are dozens of these. here are some simple ones:

      https://www.npmjs.com/package/routes-js
      https://github.com/tildeio/router.js/
      http://millermedeiros.github.io/crossroads.js/

     many more are available. just google "javascript routing library"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 8, 2016 3:25 PM
  • User-129908252 posted
    app.run(function($rootScope, $location) {
        $rootScope.$on('$locationChangeSuccess', function() {
            if($rootScope.previousLocation == $location.path()) {
                console.log("Back Button Pressed");
            }
            $rootScope.previousLocation = $rootScope.actualLocation;
            $rootScope.actualLocation = $location.path();
        });
    });

    This will also trigger if the user clicks the Forward button or if they navigate to the last page they were on,
    rather than clicking the back button
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 22, 2016 1:15 PM