Domanda

I am experimenting with Sammy js and have it configured as shown below

 Sammy(function () {

        //get individual email details when an item is clicked
        this.get('#:EmailID', function () { self.openEmail(this.params.EmailID) });

        //get inbox view when default page is visited
        this.get('', function () { self.getInbox() });
    }).run();

The trouble is with the second catch all function that displays the inbox when no matches are found. It intercepts all javascript redirects. For example, I have a button that redirects the user to their account page as shown below

<a class="btn" href="~/Users/Account">Account</a>

However, when they click on this link, it is intercepted by Sammy and the getInbox() function is run. How can I allow the redirect to proceed if the URL in window.location is a different page?

È stato utile?

Soluzione

Solved it by adding the URL of my base page to the default catch all function as shown below

//get inbox view when default page is visited
this.get('User/Messages', function () { self.getInbox() });

This prevents the URL link from being trapped by the route if it points to a different page.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top