I'm trying to create a dynamic slider through jQuery like so:
(this isn't the full script, I've just cut relevant pieces
$("head").append( $("<link rel=\"javascript\" type=\"text/css\">").attr("href", sliderjs) );
$('<script>$("#Glide").glide({ type: "carousel"});</' + 'script>').appendTo(document.body);
I can see the slider.js file has loaded correctly, but it's not being recognised by the Glide script, because I'm loading this in separately I thought maybe it wasn't loading in the right order.
I tried adding the append part to:
setTimeout(function() {
$('<script>$("#Glide").glide({ type: "carousel"});</' + 'script>').appendTo(document.body);
}, 300);
to give it time to load in, but it doesn't seem to matter, it still doesn't recognise it.
I've added them to the HTML and that works absolutely fine, but I can't see what I would need to do to get this to work in the right order?