From 770efee25fd439ca79432ec6b56f36fdd40f26d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Mon, 7 Aug 2017 18:16:43 +0200 Subject: [PATCH] Add support for disabled attribute to the d-checkbox component --- .../javascripts/discourse/components/d-checkbox.js.es6 | 8 +++----- .../discourse/templates/components/d-checkbox.hbs | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/components/d-checkbox.js.es6 b/app/assets/javascripts/discourse/components/d-checkbox.js.es6 index 5e50bf98eda..91f6d6f0a68 100644 --- a/app/assets/javascripts/discourse/components/d-checkbox.js.es6 +++ b/app/assets/javascripts/discourse/components/d-checkbox.js.es6 @@ -3,9 +3,8 @@ import { on } from "ember-addons/ember-computed-decorators"; export default Ember.Component.extend({ tagName: 'label', - didInsertElement() { - this._super(); - + @on("didInsertElement") + _init() { const checked = this.get('checked'); if (checked && checked !== "false") { this.$('input').prop('checked', true); @@ -18,8 +17,7 @@ export default Ember.Component.extend({ }, @on('willDestroyElement') - willDestroyElement() { - this._super(); + _clear() { this.$('input').off('click.d-checkbox'); } }); diff --git a/app/assets/javascripts/discourse/templates/components/d-checkbox.hbs b/app/assets/javascripts/discourse/templates/components/d-checkbox.hbs index f39a68e79c9..8ec5979a1fd 100644 --- a/app/assets/javascripts/discourse/templates/components/d-checkbox.hbs +++ b/app/assets/javascripts/discourse/templates/components/d-checkbox.hbs @@ -1,2 +1,2 @@ - + {{i18n label}}