mirror of
https://github.com/KevinMidboe/vue-js-modal.git
synced 2025-10-29 18:00:20 +00:00
Merge pull request #139 from yeknava/patch-1
Enter key triggers default button
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
:adaptive="true"
|
:adaptive="true"
|
||||||
:clickToClose="clickToClose"
|
:clickToClose="clickToClose"
|
||||||
:transition="transition"
|
:transition="transition"
|
||||||
|
@keyup.enter="clickDefault"
|
||||||
@before-open="beforeOpened"
|
@before-open="beforeOpened"
|
||||||
@before-close="beforeClosed"
|
@before-close="beforeClosed"
|
||||||
@opened="$emit('opened', $event)"
|
@opened="$emit('opened', $event)"
|
||||||
@@ -85,6 +86,28 @@
|
|||||||
} else {
|
} else {
|
||||||
this.$modal.hide('dialog')
|
this.$modal.hide('dialog')
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
clickDefault () {
|
||||||
|
if(this.buttons === undefined || !this.buttons) {
|
||||||
|
this.$modal.hide('dialog')
|
||||||
|
}
|
||||||
|
if(this.buttons.length > 1) {
|
||||||
|
return this.buttons.map(button => {
|
||||||
|
if(button.default != undefined && button.default == true) {
|
||||||
|
if (typeof button.handler === 'function') {
|
||||||
|
return button.handler()
|
||||||
|
} else {
|
||||||
|
this.$modal.hide('dialog')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if(this.buttons.length == 1) {
|
||||||
|
if (typeof this.buttons[0].handler === 'function') {
|
||||||
|
return this.buttons[0].handler()
|
||||||
|
} else {
|
||||||
|
this.$modal.hide('dialog')
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user