atst/js/components/checkbox_input.js
2019-09-10 13:16:16 -04:00

35 lines
585 B
JavaScript

import { emitEvent } from '../lib/emitters'
export default {
name: 'checkboxinput',
props: {
name: String,
initialChecked: Boolean,
},
data: function() {
return {
isChecked: this.initialChecked,
}
},
created: function() {
emitEvent('field-mount', this, {
optional: this.optional,
name: this.name,
valid: this.isChecked,
})
},
methods: {
onInput: function(e) {
emitEvent('field-change', this, {
value: e.target.checked,
name: this.name,
valid: this.isChecked,
})
},
},
}