From 901c8c8f71ea4f5f0e04cdc261a987a684948fa7 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 4 Mar 2024 10:23:45 +0100 Subject: [PATCH] refs #6911 feat: qFormMixin keyup.enter --- src/boot/qformMixin.js | 20 ++++++++++++++++++++ src/boot/quasar.js | 6 ++++++ 2 files changed, 26 insertions(+) create mode 100644 src/boot/qformMixin.js create mode 100644 src/boot/quasar.js diff --git a/src/boot/qformMixin.js b/src/boot/qformMixin.js new file mode 100644 index 000000000..daca84eef --- /dev/null +++ b/src/boot/qformMixin.js @@ -0,0 +1,20 @@ +import { QTable, QForm } from 'quasar'; + +export default { + inject: { QForm }, + component: { QForm }, + components: { QForm }, + extends: { QForm }, + mounted: function () { + if (this.$el?.classList?.contains('q-form')) + if (this.$el?.id !== 'searchbarForm') { + let that = this; + + document.addEventListener('keyup', function (evt) { + if (evt.keyCode === 13) { + that.onSubmit(); + } + }); + } + }, +}; diff --git a/src/boot/quasar.js b/src/boot/quasar.js new file mode 100644 index 000000000..a8d9b7ad9 --- /dev/null +++ b/src/boot/quasar.js @@ -0,0 +1,6 @@ +import { boot } from 'quasar/wrappers'; +import qFormMixin from './qformMixin'; + +export default boot(({ app }) => { + app.mixin(qFormMixin); +});