Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handlebars link-to helper with Bootstrap navbar

I found a post on here that said in order to use Twitter Bootstrap's navbar with Ember and Handlebars, so that the <li> gains the 'active' class automatically, I could do this:

    {{#link-to 'dashboard' tagName="li" href=false}}
        {{#link-to 'dashboard'}}
            Dashboard
        {{/link-to}}
    {{/link-to}}

It works, however, I've just enabled Ember's LOG_TRANSITIONS and it shows me that the views are getting transitioned to twice for the links in the navbar.

How do I correctly render the navbar list with Handlebars and avoid this double loading?

like image 435
bcmcfc Avatar asked Dec 20 '22 22:12

bcmcfc


1 Answers

The problem is that you have two link-to's for dashboard route.

You have two options:

Use the link-to just in the li tag:

{{#link-to 'dashboard' tagName="li" href=false}}
    <a href="#">Dashboard</a>
{{/link-to}}

Use bubbles=false in the inner link-to:

{{#link-to 'dashboard' tagName="li" href=false}}
    {{#link-to 'dashboard' bubbles=false}}
        Dashboard
    {{/link-to}}
{{/link-to}}

So the event isn't propagated.

like image 143
Marcio Junior Avatar answered Dec 30 '22 10:12

Marcio Junior