Hunrik
Hunrik

Reputation: 483

Bootstrap dropdown not working but used to

I have a bootstrap menu whith a dropdown. It used to work but something happened. I click on it and nothing happens.

<ul class="nav navbar-nav navbar-right">
    <li class="{% if this.page.id == 'home' %}active{% endif %}"><a href="{{ 'home'|page }}">Főoldal</a></li>
    {% if user %}
    <li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{ user.name }}<span class="caret"></span></a>
        <ul class="dropdown-menu" role="menu">
            <li><a href="{{ 'new-post'|page}}">New post</a>
            </li>
            <li class="divider"></li>
            <li><a data-request="onLogout" data-request-data="redirect: '/good-bye'">Logout</a>
            </li>
        </ul>
    </li>
    {% else %}
    <li class=""><a href="{{ 'auth'|page }}">Login</a></li>
    {% endif %}
</ul>

At the bottom:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="{{ 'assets/js/bootstrap.min.js'|theme }}"></script>

Update: Checked with the original example but still not working so the problem is somewhere in the js part. But the JS is there.

Upvotes: 0

Views: 65

Answers (2)

Hunrik
Hunrik

Reputation: 483

Solved. The bootstrap js was included twice. I didnt noticed it because the bootstrap wasnt in its name.

Upvotes: 0

Dev
Dev

Reputation: 6786

u missed a </ul> after {% endif %} see http://jsfiddle.net/26vpc9o3/1/

 <ul class="nav navbar-nav navbar-right">
     <li class="{% if this.page.id == 'home' %}active{% endif %}"><a href="{{ 'home'|page }}">Főoldal</a></li>
{% if user %}
    <li class="dropdown">
     <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{ user.name }}<span class="caret"></span></a>
    <ul class="dropdown-menu" role="menu">      
        <li><a href="{{ 'new-post'|page}}">New post</a></li>
        <li class="divider"></li>
        <li><a data-request="onLogout" data-request-data="redirect: '/good-bye'">Logout</a></li>
    </ul>
    </li>
    {% else %}
    <li class=""><a href="{{ 'auth'|page }}">Login</a></li> 
    {% endif %}
    </ul>

Upvotes: 1

Related Questions