Reputation: 15660
I need to be able to create a line that looks like this:
<script type="text/javascript" src="http://localhost/myapp/themes/testtheme/js/fancybox/jquery.fancybox.pack.js?v=2.1.2"></script>
I've tried the following:
Assets::add_js('fancybox/jquery.fancybox.pack.js?v=2.1.2');
but that fails - it doesn't add anything at all to my header. Using:
Assets::add_js('fancybox/jquery.fancybox.pack.js');
adds a script tag, but without the version number. It just looks like this:
<script src="http://localhost/myapp/bonfire/themes/testtheme/js/fancybox/jquery.fancybox.pack.js" type="text/javascript" ></script>
Can you tell me how to add the ?v=2.1.2 to my script tag? Thanks!
Upvotes: 1
Views: 811
Reputation: 102765
I'm not too familiar with Bonfire, but I took a quick look at the source code.
I'm pretty sure the reason it's not displaying the script tag is because it's looking for a file with the literal name fancybox/jquery.fancybox.pack.js?v=2.1.2
, which doesn't exist.
I think you can trick it by using a full url, so it thinks it's an external script and won't check if the file exists. Something like:
Assets::add_js(base_url().'fancybox/jquery.fancybox.pack.js?v=2.1.2');
It's never pleasant to have to use workarounds like this and can sometimes cause side effects, so I would suggest you point this out to the developer(s) of Bonfire.
Another thing to note, ?v=2.1.2
is nothing more than a cache-busting trick for when you update the file (it makes users re-download the file when the query string is changed), so consider whether or not you actually need it.
Upvotes: 1