From 6bcf7dee288c0ef3eb17bf8e8a19c60e8676ea50 Mon Sep 17 00:00:00 2001 From: Andrew Croce Date: Wed, 8 Aug 2018 11:41:27 -0400 Subject: [PATCH] No need for 'valid' data Add name prop, and event emitter for changes --- js/components/text_input.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/components/text_input.js b/js/components/text_input.js index 4c06ff81..e027a800 100644 --- a/js/components/text_input.js +++ b/js/components/text_input.js @@ -9,6 +9,7 @@ export default { }, props: { + name: String, validation: { type: String, default: () => 'anything' @@ -21,7 +22,6 @@ export default { data: function () { return { - valid: false, showError: false, showValid: false, mask: inputValidations[this.validation].mask, @@ -60,8 +60,14 @@ export default { } else if (invalidate) { this.showError = true } - this.valid = valid this.showValid = valid + + // Emit a change event + this.$emit('fieldChange', { + value, + valid, + name: this.name + }) }, _validate: function (value) {