wire-elements / modal

Livewire component that provides you with a modal that supports multiple child modals while maintaining state.
MIT License
1.09k stars 129 forks source link

How to open additional modal from modal? #383

Closed stojankukrika closed 7 months ago

stojankukrika commented 8 months ago

Hi, How to open modal from modal and close parent modal? Or How to close current modal and open new one.

My scenario is: user click on generate some token, and I like to show him a new token in new modal because I do not want to show token in the past, just that time it will shows up and will be masked in future. To prevent hackers to use it again in some other places.

Is that possible?

Best regards and thank you fro this package, it's AWESOME!

Krato commented 8 months ago

@PhiloNL After upgrade to v2 using Livewire 3, this is not working. Can you check it please?

Thank you!

Example: If you call from Livewire component that already is a modal:

$this->dispatch('openModal', component: 'my-awesome-second-modal');

First modal is hide, but second is not showing. Is giving a js error:

Uncaught TypeError: Cannot read properties of null (reading 'before')  at Block.appendChild (livewire.esm.js:5392:25)
GBry commented 7 months ago

Having the same error. The thing is, it's not happening on every modal, another one where I implemented a two step modal works.

PhiloNL commented 7 months ago

Can you give this a try in the latest release? Thanks!

PhiloNL commented 7 months ago

If this still occurs, let me know.

fkhrdinn commented 2 months ago

Can you give this a try in the latest release? Thanks!

Hi, I encountered the same problem like the author stated. First modal went to hide but second one is not showing and gave the same js error. Uncaught TypeError: Cannot read properties of null (reading 'before').

ggg
camerontucker commented 1 month ago

@fkhrdinn try changing inject_morph_markers => false in livewire.php. This fixed my error, which only happens in production.

FWIW https://github.com/livewire/livewire/discussions/6965