2

Twitter bootstrap accordion not working with Sammy.js

Is a similar question but was never answered.

I am creating an affixed Twitter Bootstrap side nav-list and using has based href's but when I click on them Sammy is trying to catch the routes. Since I am dynamically creating the Id's and href's I can prevent them from ever matching an existing route but it constantly hits the console with errors. I am sure in production they won't show up but is there anything that can be done to prevent this?

        <ul class="nav nav-list affix">
            <!-- ko foreach: sections -->
                <li class="nav-header"><span data-bind="text: navDesc"></span></li>
                    <!-- ko foreach: paragraphs -->
                    <li><a data-bind="attr: { href: '#' + navProp() }"><span data-bind="text: navDesc"></span> <i class="icon-chevron-right"></i></a></li>
                    <!-- /ko -->
            <!-- /ko -->
        </ul>

I know this will be fixed in the next version of Durandal but just checking any other options.

Community
  • 1
  • 1
PW Kad
  • 14,953
  • 7
  • 49
  • 82

1 Answers1

1

Durandal 1.2 provides a guardRoute method, which will allow you to intercept the call before it reaches sammy.

Check out How to handle / ignore a bad route with durandal? for more information.

Community
  • 1
  • 1
RainerAtSpirit
  • 3,723
  • 1
  • 17
  • 18
  • Rainer I am sure this is headed down the right path but I don't know the name of the route to guard before activate my shell.js as my routes are dynamically created based off an entities property, can you be a bit more descriptive of how this would work? Are you saying set a predecessor like /#/#guarded(and then the nav id?) – PW Kad Jun 18 '13 at 21:01
  • Not sure if I can be more specific as it's your app ;-). Looking at the provided example how to you make sure that navProp() doesn't interfere with any manually routes at the moment? Adding a prefix for all routes that should be ignored seems to be a viable options. – RainerAtSpirit Jun 18 '13 at 22:12
  • Rainer after two weeks of trying to get this to work I don't think this is the solution. Router is catching everything j do as a bad route – PW Kad Jul 03 '13 at 14:15
  • sorry to hear. Durandal 2.0 is coming closer and I've just updated https://github.com/dFiddle/dFiddle-2.0. This is still using alpha bits, but it looks as if the new router is already pretty stable. – RainerAtSpirit Jul 03 '13 at 15:59