Get 2024 Templates Mega Bundle!$1000 worth of 19 Bootstrap HTML, Vue & React Templates + 3 Vector Sets for just $9
Get for 99$

Modal and relatedTarget


Hello,

I've switched to Metronic 9 and I'm having a problem with the modals.
I'm using a single modal, called by several buttons on the same page. Each button must send an reference to the modal (data-reference=“12” for example).
With Bootstrap, it's possible to do this:

$("#myModal").on("show.bs.modal", function (event) {
let button = $(event.relatedTarget); // Get button
let recipient = button.data("reference"); // Get data-reference value form button

var modal = $(this);
modal.data("reference", recipient);
});


But with metronic, I don't see anything in the documentation allowing me to pass information between the button and the modal.

Thanks for your help.


Text formatting options
Submit

Replies (2)


Thank you for your feedback



Hi,

Please try to use modal.getTargetElement() API method to get the DOM element that triggered the display of the KTModal instance. For more info please refer to KTModal API Reference.

Regards.


Text formatting options
Submit
Text formatting options
Submit