linstula / ember-cli-bootstrap

ember-cli addon for Twitter Bootstrap
37 stars 20 forks source link

Please add a link-li component #19

Closed kristianmandrup closed 9 years ago

kristianmandrup commented 10 years ago

Solution to creating an active bootstrap navbar link:

http://stackoverflow.com/questions/14328295/how-do-i-bind-to-the-active-class-of-a-link-using-the-new-ember-router

app/components/link-li.js

export default Em.Component.extend({
    tagName: 'li',
    classNameBindings: ['active'],
    active: function() {
        return this.get('childViews').anyBy('active');
    }.property('childViews.@each.active')
});

Usage

        {{#link-li}}
            {{#link-to "squares.index"}}Squares{{/link-to}}
        {{/link-li}}
        {{#link-li}}
            {{#link-to "games.index"}}Games{{/link-to}}
        {{/link-li}}
        {{#link-li}}
            {{#link-to "about"}}About{{/link-to}}
        {{/link-li}}

Thanks :)

linstula commented 9 years ago

ember-cli-bootstrap is intended to be an easy way to import https://github.com/ember-addons/bootstrap-for-ember into your ember-cli app. If you'd like to see a 'link li' component I'd suggest getting in touch with the maintainer and see if it's something they're interested in supporting.