My issue might looks very super simple but I am struggling how to load items into a select using Jquery. I am using Materialize theme found here:
BUT if I move the append code outside of $( document ).ready()
it works. But I am trying to load them inside it while page loads.
Why is this not working? How do I solve this?
CodePudding user response:
there are many reason for this. But the most common is conflicts between your code and other js or jquery codes - so just run your code in no conflict mode by simply adding this line above your document.ready() function block.
$.noConflict();
and then replace all jQuery shortcut $ in you code by jQuery.
Or for shorter version:
var jq = $.noConflict();
and replace all jQuery shortcut $ in you code by jq.
CodePudding user response: