Accesing JQuery in widget template
Unsolved
Plugin Development
-
Re: JQuery in Widget Template
According to this thread, you could load Jquery in a widget template using app.loadJQueryUI(). This doesn't work anymore as that field isn't available at the time the time the widget loads. Is there a way to execute the script as soon as the page finishes loading? It has to be in the template since the code uses variables set in the admin widget panel. -
Javascript embedded in the widget can't access the jquery object on page load since jquery hasn't loaded yet. You can use something like this
(function() { function onLoad() { // widget code } if (window.jQuery) { onLoad(); } else { window.addEventListener('DOMContentLoaded', onLoad); } })();
Copyright © 2024 NodeBB | Contributors