Use form mixin for add field change handler

This commit is contained in:
Patrick Smith
2018-08-23 16:33:13 -04:00
parent f599abb5dd
commit b8a983f4dc
4 changed files with 24 additions and 37 deletions

14
js/mixins/form.js Normal file
View File

@@ -0,0 +1,14 @@
export default {
mounted: function () {
this.$root.$on('field-change', this.handleFieldChange)
},
methods: {
handleFieldChange: function (event) {
const { value, name } = event
if (typeof this[name] !== undefined) {
this[name] = value
}
},
}
}