From d94942118e338edd639db0f094c77ce057a76bf3 Mon Sep 17 00:00:00 2001 From: Wil Stead Date: Wed, 31 May 2017 13:11:13 -0400 Subject: [PATCH] Add access to click event on buttons Used built-in Vue $event special variable to pass DOM click event to button onclick functions as a third parameter. --- src/formGenerator.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/formGenerator.vue b/src/formGenerator.vue index 8fde82e2..de509fe3 100644 --- a/src/formGenerator.vue +++ b/src/formGenerator.vue @@ -11,7 +11,7 @@ div.vue-form-generator(v-if='schema != null') .field-wrap component(:is='getFieldType(field)', :disabled='fieldDisabled(field)', :model='model', :schema='field', :formOptions='options', @model-updated='modelUpdated', @validated="onFieldValidated") .buttons(v-if='buttonVisibility(field)') - button(v-for='btn in field.buttons', @click='buttonClickHandler(btn, field)', :class='btn.classes') {{ btn.label }} + button(v-for='btn in field.buttons', @click='buttonClickHandler(btn, field, $event)', :class='btn.classes') {{ btn.label }} .hint(v-if='field.hint') {{ field.hint }} .errors.help-block(v-if='fieldErrors(field).length > 0') span(v-for='(error, index) in fieldErrors(field)', track-by='index') {{ error }} @@ -29,7 +29,7 @@ div.vue-form-generator(v-if='schema != null') .field-wrap component(:is='getFieldType(field)', :disabled='fieldDisabled(field)', :model='model', :schema='field', :formOptions='options',@model-updated='modelUpdated', @validated="onFieldValidated") .buttons(v-if='buttonVisibility(field)') - button(v-for='btn in field.buttons', @click='buttonClickHandler(btn, field)', :class='btn.classes') {{ btn.label }} + button(v-for='btn in field.buttons', @click='buttonClickHandler(btn, field, $event)', :class='btn.classes') {{ btn.label }} .hint(v-if='field.hint') {{ field.hint }} .errors.help-block(v-if='fieldErrors(field).length > 0') span(v-for='(error, index) in fieldErrors(field)', track-by='index') {{ error }} @@ -276,8 +276,8 @@ div.vue-form-generator(v-if='schema != null') return field.featured; }, - buttonClickHandler(btn, field) { - return btn.onclick.call(this, this.model, field, this); + buttonClickHandler(btn, field, event) { + return btn.onclick.call(this, this.model, field, event, this); }, // Child field executed validation