Uncaught ReferenceError: $ is not defined
How do I add jquery for the error that occurs because there is no jQuery specific to the metronic template?
Thanks for help!
A good internet connection is important for the game. primus internet has proved to be a reliable partner for my online needs. The connection speed allows me to watch HD videos and play online games without delay. They have excellent support, always ready to help solve any problem. I am happy with my choice and recommend them to anyone looking for a reliable internet provider.
Hi,
If you are trying to run a jquery code when the Metronic main bundle js that includes jquery snd other plugins you may get that error. To fix this just run your code on document ready event by refering to our custom js scripts under src/sass/
.
Also please double check that sll dependecy js scripts are fully loaded.
Regards.
Hi Sean,
I think that is exactly the error that cut me off, when I upgraded from 8.0.38 to 8.1 AND I STILL HAVE THIS ERROR TILL NOW (Thought about not use anymore jQuery due to this, but a lots of components we are using are based on jQuery)
I mean all my code was working like a charm,
Once I upgraded to 8.1, I got errors everywhere I used Select2 in my Modal on ajax, and since Select2 is jQuery dependent, I got that error of "Uncaught ReferenceError: $ is not defined"
Now I got the issue ,
thank also to user BüÅra (OP), to bring that up,
But how to from now on to use run my code on document ready event ?????
I wen as you refering to go to you custom js scripts under src/sass/. as you said above but didn't find nothing !!!
But instead I sneak up on your js code and found something useful, is this the code you are refering too (I took example of a KTImage):
// On document ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', KTImageInput.init);
} else {
KTImageInput.init();
}
If so, please advice, bair with me witness with this one please .
NB : Thins is not just an issue for me, it's the whole Web project we are building that rely on, please advice.
Thank you Sean for everything, wait for you simple and accurate explanation (As JS is not my strength point)
Thank you.
Hi,
Thank you for the feedback.
Have you tried to use the below KTUtil API ? Within this handler you can init your custom scripts and access all plugins from assets/plugins/global/plugins.bundle.js
including jQuery.
KTUtil.onDOMContentLoaded(function () {
// run this on DOM ready
});
<script src="assets/plugins/global/plugins.bundle.js"></script>
<script src="assets/js/scripts.bundle.js"></script>
This thread Sean is GOLD.
It avoided me a hell of problem, now I know exactly what was messed up.
This Thred and thoses snippets should be Pinned up, ;) for later user.
Thank you so much Sean.
https://imgur.com/a/pmQqwmD
I have file application.html.haml
I render other pages in this file with ruby ââspecific code.
but jquery doesn't work on the pages I include in it.
so it seems to work only on the typed page.
It doesn't work on pages rendered on that page.
I don't understand your solution, what should I do? js files seem to be loaded successfully on the page.
How can I use jquery in my project?