Message box input press `Enter` to confirm
See original GitHub issueVue: v2.6.12
BootstrapVue: v2.21.2
Instead of manually clicking OK
, how to press Enter
to confirm?
let text
this.$bvModal.msgBoxConfirm(<input vModel={text} />)
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
BootstrapVue message box input press `Enter` to confirm
I've figured this out: const modalId = 'modalId' const ok = () => this.$bvModal.hide(modalId) let text this.$bvModal.msgBoxConfirm(<input ...
Read more >How to Detect the Enter Key Press in a Text Input Field Using ...
Answer: Use the keypress event. To check whether a user has pressed Enter key while on specific input, you can use the keypress...
Read more >How To Use the ENTER Key from Edit Controls in a Dialog Box
There are a few ways to enable the use of the ENTER key to move between edit controls. One method is to make...
Read more >Interaction: alert, prompt, confirm
It shows a modal window with a text message, an input field for the visitor, and the buttons OK/Cancel. title: The text to...
Read more >Window.confirm() - Web APIs - MDN Web Docs
window.confirm() instructs the browser to display a dialog with an optional message, and to wait until the user either confirms or cancels ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Listen for the hide event on root.
this.$root.$on("bv::modal::hide", someMethod);
When the method is called it’s passed a bvEvent parameter, which you can callpreventDefault()
on if you dont want to hide the modal. It also includes the ID of the modal which was closed, and which trigger was used.Here’s a rough example. https://codepen.io/Hiws/pen/QWdjojm
You can supply an
id
in theoptions
object, and then usethis.$bvModal.hide('my-modal-id')
inside akeyup
event on your input, which looks for the press of theEnter
key (keycode13
). You can then call a separate method which handles your logic and hide your modal.Example
https://codepen.io/Hiws/pen/ExZVExB
I’ve also opened a PR (https://github.com/bootstrap-vue/bootstrap-vue/pull/6523), which adds an optional parameter to the
$bvModal.hide
method, which allows you to supply a trigger. By supplying the trigger ofok
, it will close the modal as if theOK
button was pressed.For example:
$bvModal.hide('my-modal-id', 'ok')
. This would work withcancel
,backdrop
and other triggers as well, even custom ones.