question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modal closes always on ok button

See original GitHub issue

I have a modal and I have everything working except that when I click on the OK button the modal dissapears. I want to keep the modal open if there are errors in the supplied data.

My modal looks like this: <b-modal id="editModal" :title="editModalTitle" @ok="saveData" @close="clearData" hide-header-close>

I have tried returning false in saveData(e) { return false; } however that doesn’t work

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
alexsasharegancommented, Jul 11, 2017

Check out the docs on the modal component under Prevent Closing: https://bootstrap-vue.js.org/docs/components/modal#prevent-closing

You should be able to call e.cancel() in the @ok handler. Keep in mind that this is done synchronously, so any async stuff will require cancelling synchronously, and then manually closing in the async callback logic.

1reaction
jonalxhcommented, Jan 6, 2021

@chamra Try with the following:

// In your template section
<b-modal @ok="validate"></b-modal>

// In your methods (script) section
validate(evt) {
   evt.preventDefault() // It will prevent modal dismiss
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning on modal close - Stack Overflow
Add class closefirstmodal in Form Modal Header / Footer Close button to invoke the warning modal with jQuery click function and bootstrap modal...
Read more >
Modal | Components - BootstrapVue
In this case use the hide event to control cancelling of the modal close. Event hide is always emitted, even if ok ,...
Read more >
Solved: Modal windows - the "OK" button - JMP User Community
The OK button or its "equivalent" is required in a modal window. The point is to construct your modal window so that the...
Read more >
modal windows - Are "close" and "x" on a popup redundant?
Yes: Don't place a X button nor a Close button, because you don't want to give the user the easiest and fastest way...
Read more >
How to change the position of modal close button in bootstrap?
× gives the cross icon. · data-dismiss switches the display property of modal element from “block” to “none”. · You can shift this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found