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

Get reference to clicked element in modal onShow callback #1007

Open
AngeloKarugo opened this issue Dec 11, 2024 · 0 comments
Open

Get reference to clicked element in modal onShow callback #1007

AngeloKarugo opened this issue Dec 11, 2024 · 0 comments

Comments

@AngeloKarugo
Copy link

AngeloKarugo commented Dec 11, 2024

Would be nice get a reference to the element that was clicked (if available) to trigger Modal.show() in the callback function.

Something like:

<button id="modalToggleId" data-modal-target="modalEl" data-modal-toggle="modalEl">...</button>

<div id="modalEl">...</div>

<script>
    modalOptions = {
        onShow: (clickedElement: HTMLElement | undefined) {
            if (clickedElement) {
                clickedElement.innerHtml = "Clicked";
            }
        },
    }
    const modal = new Modal(document.getElementById("modalEl"), modalOptions);
</script>
@AngeloKarugo AngeloKarugo changed the title Reference to clicked element in modal event listener callbacks Reference to clicked element in modal show callback Dec 11, 2024
@AngeloKarugo AngeloKarugo changed the title Reference to clicked element in modal show callback Reference to clicked element in modal onShow callback Dec 11, 2024
@AngeloKarugo AngeloKarugo changed the title Reference to clicked element in modal onShow callback Get reference to clicked element in modal onShow callback Dec 11, 2024
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

1 participant