Closed aliqasemzadeh closed 2 years ago
Publish the package view and remove data-bs-backdrop="static"
For users who want only some modals to have a static backdrop, add the modal-static
class to the modal-content
element of your modal, then update your modals.js
file accordingly. :)
// Bootstrap 4 users
const modalsElement = document.getElementById('laravel-livewire-modals');
const hasStaticModal = (el) => $(el).find('.modal-content.modal-static').length > 0;
Livewire.on('showBootstrapModal', () => {
$(modalsElement).attr('data-backdrop', hasStaticModal(modalsElement) ? 'static' : null);
$(modalsElement).modal('show');
});
// Bootstrap 5
import {Modal} from 'bootstrap';
const modalsElement = document.getElementById('laravel-livewire-modals');
const hasStaticModal = (el) => el.querySelector('.modal-content.modal-static') != null
Livewire.on('showBootstrapModal', () => {
let modal = Modal.getInstance(modalsElement);
if (!modal) {
modalsElement.setAttribute('data-bs-backdrop', hasStaticModal(modalsElement) ? 'static' : null);
modal = new Modal(modalsElement);
}
modal.show();
});
Hi I think we need close modal on click out side of modal.