I have a bootstrap button group which is dynamically created. So I created a button component which has a different icon and text.
For now I have assigned the action to the span inside the button.
sample-component.js
export default Ember.Component.extend({
tagName: 'button',
actions:{
triggerStatus:function(){
this.sendAction('triggerStatus',this.get('dataId'),this.get('type'));
}
},
didInsertElement: function(){
//is it possible to assign action here
}
}
sample-component.hbs
<span class="glyphicon glyphicon-{{icon}}" aria-hidden="true" {{action "triggerStatus"}}></span>
I tried this.set('action','triggerStatus') inside didInsertElement but it didn't work out. Can someone suggest me how to assign a action to a component within the javascript file itself? Is it possible to do so?
Aucun commentaire:
Enregistrer un commentaire