mirror of
https://github.com/discourse/discourse.git
synced 2025-02-06 04:34:59 +08:00
26 lines
685 B
JavaScript
26 lines
685 B
JavaScript
import { on } from "ember-addons/ember-computed-decorators";
|
|
|
|
export default Ember.Component.extend({
|
|
tagName: 'label',
|
|
|
|
didInsertElement() {
|
|
this._super();
|
|
|
|
const checked = this.get('checked');
|
|
if (checked && checked !== "false") {
|
|
this.$('input').prop('checked', true);
|
|
}
|
|
|
|
// In Ember 13.3 we can use action on the checkbox `{{input}}` but not in 1.11
|
|
this.$('input').on('click.d-checkbox', () => {
|
|
Ember.run.scheduleOnce('afterRender', () => this.sendAction('change', this.$('input').prop('checked')));
|
|
});
|
|
},
|
|
|
|
@on('willDestroyElement')
|
|
willDestroyElement() {
|
|
this._super();
|
|
this.$('input').off('click.d-checkbox');
|
|
}
|
|
});
|