22 lines
491 B
JavaScript
Raw Normal View History

import { next } from "@ember/runloop";
import Component from "@ember/component";
import { observes, on } from "discourse-common/utils/decorators";
2016-09-09 15:57:44 -04:00
export default Component.extend({
2018-06-15 17:03:24 +02:00
tagName: "label",
2016-09-09 15:57:44 -04:00
click(e) {
e.preventDefault();
this.onChange(this.radioValue);
2016-09-09 15:57:44 -04:00
},
2018-06-15 17:03:24 +02:00
@observes("value")
@on("init")
2016-09-09 15:57:44 -04:00
updateVal() {
const checked = this.value === this.radioValue;
next(
() => (this.element.querySelector("input[type=radio]").checked = checked)
);
},
2016-09-09 15:57:44 -04:00
});