Using jQuery in widgets
Unsolved
Technical Support
-
@julian here's the thing. If I access the post via the homepage, then the jquery code fires without issue as the library is already loaded.
However, if I load the URL directly, the jquery fails as the library isn't loaded in time. If using a vanilla js will fire if the page is accessed directly then I'm happy to do that.
-
@baris @julian found a much simpler way to do this
<script> if (!window.jQuery) { window.addEventListener('load', function() { $(document).ready(function() { $("#resolved").appendTo('[data-index="1"]:first-of-type'); }) }) } else { $(document).ready(function() { $("#resolved").appendTo('[data-index="1"]:first-of-type'); }) } </script>
Copyright © 2024 NodeBB | Contributors