Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to capture Modal close event #271

Open
azizabbas opened this issue Oct 3, 2024 · 6 comments
Open

How to capture Modal close event #271

azizabbas opened this issue Oct 3, 2024 · 6 comments

Comments

@azizabbas
Copy link

Hi,

I was wondering if I can capture Modal close event.

For example, if I am using a Delete confirmation Modal. How I can capture click on little close icon on top right of the Modal?

Image

Thanks for your help and support so far.

Aziz Abbas

@dayemsiddiqui
Copy link

Hi you can use wire:click and call your relevant livewire method when the close button is clicked

@azizabbas
Copy link
Author

azizabbas commented Oct 3, 2024

Hi, Thanks for your reply on this one.

Actually, I am asking about that little cross icon on top-right corner of the box.

Seems like we don't have any control on that icon.

@bzarzuela
Copy link

bzarzuela commented Oct 3, 2024

Caleb mentioned that he uses <dialog> for modals. If you can acquire a reference to it, you can add a listener as described in https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog#examples

@azizabbas
Copy link
Author

Are you saying that we have to go back to javascript to capture this is one tiny thing. Well, this is bit annoying

@ju5t
Copy link

ju5t commented Oct 3, 2024

@azizabbas you could register an on click the data-flux-modal-close attribute too. It doesn't get much easier than that. And you can always override the the flux:modal.close to emit a JS event if it's more common.

This isn't a bug though, it's better to post these things in discussions.

@azizabbas
Copy link
Author

Thank you all for taking your time and reply to my post.

I know how javascript works but I am using Livewire/Flux so that I dont have to write javascript. At least that is what I want at most :)

Anyways, I published related Modal code and remove that little cross icon and now everything is under my control.

Hopefully, in future versions of Flux we have more options and control on Modal and other components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants