Skip to content

Commit d949421

Browse files
authored
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.
1 parent cabc1e4 commit d949421

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/formGenerator.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ div.vue-form-generator(v-if='schema != null')
1111
.field-wrap
1212
component(:is='getFieldType(field)', :disabled='fieldDisabled(field)', :model='model', :schema='field', :formOptions='options', @model-updated='modelUpdated', @validated="onFieldValidated")
1313
.buttons(v-if='buttonVisibility(field)')
14-
button(v-for='btn in field.buttons', @click='buttonClickHandler(btn, field)', :class='btn.classes') {{ btn.label }}
14+
button(v-for='btn in field.buttons', @click='buttonClickHandler(btn, field, $event)', :class='btn.classes') {{ btn.label }}
1515
.hint(v-if='field.hint') {{ field.hint }}
1616
.errors.help-block(v-if='fieldErrors(field).length > 0')
1717
span(v-for='(error, index) in fieldErrors(field)', track-by='index') {{ error }}
@@ -29,7 +29,7 @@ div.vue-form-generator(v-if='schema != null')
2929
.field-wrap
3030
component(:is='getFieldType(field)', :disabled='fieldDisabled(field)', :model='model', :schema='field', :formOptions='options',@model-updated='modelUpdated', @validated="onFieldValidated")
3131
.buttons(v-if='buttonVisibility(field)')
32-
button(v-for='btn in field.buttons', @click='buttonClickHandler(btn, field)', :class='btn.classes') {{ btn.label }}
32+
button(v-for='btn in field.buttons', @click='buttonClickHandler(btn, field, $event)', :class='btn.classes') {{ btn.label }}
3333
.hint(v-if='field.hint') {{ field.hint }}
3434
.errors.help-block(v-if='fieldErrors(field).length > 0')
3535
span(v-for='(error, index) in fieldErrors(field)', track-by='index') {{ error }}
@@ -276,8 +276,8 @@ div.vue-form-generator(v-if='schema != null')
276276
return field.featured;
277277
},
278278
279-
buttonClickHandler(btn, field) {
280-
return btn.onclick.call(this, this.model, field, this);
279+
buttonClickHandler(btn, field, event) {
280+
return btn.onclick.call(this, this.model, field, event, this);
281281
},
282282
283283
// Child field executed validation

0 commit comments

Comments
 (0)