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.
Replies (2)
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.