I would like to prevent closing Toast when closing Modal in BootstrapVue.
Scenario:
Question: how to keep Toast stays
created() {
this.$bvModal.show('modal-form-id')
const errorToaster = {
title: 'Success',
toaster: 'b-toaster-top-center',
variant: 'success'
}
this.$bvToast.toast('Success', errorToaster)
},
methods: {
closeModal() {
this.$bvModal.hide('modal-form-id')
}
}
You can prevent closing of modal dialog by setting the beforeClose event argument cancel value to true.
To close a modal using vue. js you can use the click event i.e. @click to trigger change in modal visibility. So, whenever the close button is pressed the @click method will trigger the function associated with the action ( here, hiding the modal ).
<b-modal> supports close on ESC (enabled by default), close on backdrop click (enabled by default), and the X close button in the header (enabled by default). These features may be disabled by setting the props no-close-on-esc , no-close-on-backdrop , and hide-header-close respectively.
$bvToast. toast() method to generate on demand toasts. The method accepts two arguments: message : the content of the toast body (either a string, or an array of VNodes ).
Try to add $root.
this.$root.$bvToast.toast("Success", errorToaster);
In you errorToaster
add this no-auto-hide: true
.
Example:
const errorToaster = {
title: 'Success',
toaster: 'b-toaster-top-center',
variant: 'success',
'no-auto-hide': true,
}
Toast has auto-hide-delay
property - the number of milliseconds before the toast auto dismisses itself, so it closes with no connection to modal closing.
add to your code:
const errorToaster = {
title: 'Success',
toaster: 'b-toaster-top-center',
variant: 'success',
autoHideDelay: // default is 5000,
noAutoHide: true // in order to stay it open forever
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With