Search code examples
twitter-bootstrapsammy.js

Bootstrap drop down menu is not closed when using Sammy


For start, I'm using Bootstrap and Sammy.js in my application. I configured some of the anchors in the dropdown menu (of a dropdown button) to navigate to #/login and #/register respectively. The problem is that when I click on Login / Register links the dropdown menu doesn't close.

I also attached a screenshot taken while running in Firefox.

What am I doing wrong here?

Thank you.

Screenshot


Solution

  • The solution I ended up using is to manually handle those clicks. Bellow is the code that does that.

    $('#header').delegate('a[href="#login"],a[href="#register"]', 'click', function() {
        sammy.setLocation($(this).attr('href'));
        $(this).closest('.dropdown-menu').trigger('click');
        return false;
    });
    

    where: sammy is the instance obtained through Sammy(...)