I am calling a JS file from a bundle directory like so:
<script src="{{ asset('bundles/macppages/js/main.js') }}"></script>
which loads the JS file into the base.index.twig
In that JS file I want to add some custom css via jQuery like this:
function loadBkrndImg(){
var img = new Image();
img.src = "/bundles/macppages/images/bkrnd.0" + currentBkrndImgNum + ".jpg";
$('body').css("background-image","url('" + img.src + "')");
}
which works, but to the question:
Is this the correct way to do it using the Symfony 2 framework? In Symfony 1, there was a function you could call to pull the web dir. With Sym2, the assets are in the bundle directories, so is there a Symfony2 command for this so it is not so explicit?