Skip to content

Instantly share code, notes, and snippets.

@heat
Created May 31, 2018 16:10
Show Gist options
  • Save heat/a1df5fcb0e8bdadc1aaa7290713ac3eb to your computer and use it in GitHub Desktop.
Save heat/a1df5fcb0e8bdadc1aaa7290713ac3eb to your computer and use it in GitHub Desktop.
component bs-switch
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['btn'],
classNameBindings: ['classNameSwitch'],
classNameSwitch: Ember.computed('switch', function() {
return this.get('switch')? this.get('switchOn'): this.get('switchOff');
}),
switchOff: 'text-danger',
switchOn: 'text-success',
switch: null,
click(event) {
this.get('action')();
}
});
{{#bs-btn-switch switch=usuario.ativo action=(action "ativacaoUsuario" usuario) }}
{{#if usuario.ativo}}
<span class="glyphicon glyphicon-check"></span>
{{else}}
<span class="glyphicon glyphicon-unchecked"></span>
{{/if}}
{{/bs-btn-switch}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment