Assigning 'active' class to selected list item in EmberJS

后端 未结 12 2091
星月不相逢
星月不相逢 2020-12-08 00:34

I have a list and I\'d like to set one item as class=\"active\" automatically. Given the following bootstrap code:

12条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 01:13

    I went with:

     Ember.LinkView.reopen({
    didInsertElement:function(){
    
        if(this.$().hasClass('active')){
    
            this.$().parent().addClass('active');
    
        }
    }
    

    });

    I didn't want to use the accepted answer as I wanted to keep my li elements as plain old html. There might be a better way to check the active state but I couldn't get access to the right property.

提交回复
热议问题