flowbite icon indicating copy to clipboard operation
flowbite copied to clipboard

Get reference to clicked element in modal onShow callback

Open AngeloKarugo opened this issue 11 months ago • 0 comments

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 avatar Dec 11 '24 06:12 AngeloKarugo