I have the following code
$this->addScript('<script type="text/javascript">
$(document).ready(function() {
alert("dsf");
});
</script>');
Is it possible to add this at the bottom of my view? My reason being is it somehow always renders above the line where the jQuery library is included.
I’ve seen in the documentation they mention $scripts_for_layout, but I’m not sure how to use it.
If you want to place your JS code at a precise place in your view, you can use
But if you do want to have your JS code in the header (but after the jQuery inclusion), you can just continue to use
$this->addScript(), but make sure to place the variable$scripts_for_layoutafter the call toscript():