aliqasemzadeh / livewire-bootstrap-modal

Dynamic Laravel Livewire Bootstrap modals.
35 stars 12 forks source link

Unable to hide modal from component #4

Closed michele-grifa closed 1 year ago

michele-grifa commented 1 year ago

I'm using $this->emit('hideModal') from the component but I get the following error in the console:

Unhandled Promise Rejection: TypeError: null is not an object (evaluating 'r.Modal.getInstance(i).hide')

I have multiple modals on the page but only one visible.

Package Version: dev-master Bootstrap Version: 5.2.2 Laravel Version: 9.40.1

aliqasemzadeh commented 1 year ago

I think you miss : https://github.com/alighasemzadeh/livewire-bootstrap-modal#modal-views

michele-grifa commented 1 year ago

I already had the correct modal view, in fact the modal open normally and works.

aliqasemzadeh commented 1 year ago

Please share your code with me.

michele-grifa commented 1 year ago

Update: i re-checked the code and I noticed that I was emitting another event instead of the showModal. Now the code is correct, but when I try to show a modal I get the following error in the console:

undefined is not an object (evaluating 'this._config.backdrop')

After this error the modal is added to the dom and I see only a blur.

Modal Livewire Component

<div>
    <div id='modal_consegna_test' class="modal" tabindex="-1" wire:ignore.self>
        <div class="modal-dialog modal-xl">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">Modifica Consegna TEST</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <h5>TEST</h5>
                </div>
            </div>
        </div>
    </div>
</div>
aliqasemzadeh commented 1 year ago

@michele-grifa Check this example and JS in resource that I build for BAP. https://github.com/alighasemzadeh/bap/blob/master/resources/views/livewire/admin/user/edit.blade.php