Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

How to have a dynamic modal in Metronic with all modules support?


Hello,

I am trying to have a dynamic through which I can call an external file in php like


<a data-bs-toggle="modal" data-bs-target="#LCPS_POPUP" data-load-url="addvideocategory.php?id=".$row["id"]."\"" data-title="".$mainCatTitle."" class="menu-link px-3">...
</a>


I have a modal with LCPS_POPUP and I am opening it with:


$("#LCPS_POPUP").on("show.bs.modal", function (e) {
var loadurl = $(e.relatedTarget).data("load-url");
var title = $(e.relatedTarget).data("title");
$(this).find(".modal-body").load(loadurl);
$(this).find(".modal-title").html(title);
});
});


Popup is opening with dynamic title and content but popup is getting Metronic javascript components like image input viewer. I have tried declaring KTComponents.init(); and also KTImageInput.init(); inside the function but it does not work unless I I do:


$.getScript("./../assets/js/scripts.bundle.js", function(jd) {});


with in the function. But then javascript stops working on main page.

Please help me with this as I have been trying to solve it for 2 days now and no clue whatsoever.

Thanks


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)


Hi,

If you are using Metronic 8.1.x you can use the global Metronic core components initialiser

KTComponents.init()
as described here.

You just need to call the above init method on the modal shown event after the new HTML elements population in order to initialize the newly loaded components such as Menus, Select2, etc as defined in src/js/components/_init.js.

Regards.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
buy metronic

React Dev Vacancy

KeenThemes is looking for a Junior React or Vue developer to build awesome apps.
Apply