Search code examples
durandalsammy.js

How do I get Durandal Router to stop messing with href="#"?


I'm getting started with Durandal JS and so far it's working great.

I have an issue though - ALL my links are being intercepted by Durandal's Router (Sammy JS under the hood). How can I get it to leave my links alone? <a href="#"></a>

If there is a Sammy JS-specific alternative to the hashtag as a href to make the browser think it's a link, that'd be awesome too.


Solution

  • Durandal's router.js is an optional component, so if you don't need it you can remove the script tag that loads sammy.js and remove durandal/plugins/router as dependencies in your AMDs. If you need to partially protect some links from being handled by router then guardRoute http://durandaljs.com/documentation/Router/ is probably your best bet.

    This assumes that you're running Durandal 1.2 and not the latest code from github (work in progress), where router.js just got completely rewritten and has no dependency on sammy.js any longer.