I have twig template with that:
<script type="text/javascript">
var initParams = {
homePage: '{{ url('_homepage') }}'
};
</script>
On other hand, i have .js file with usage of initParams.homePage. The problem is PHPStorm think that my initParams is not defined. Is there the way to send defination of inTwig js variables to global PHPStorm scope?
Thanks in advance!
When using jslint to inspect you Javascript, you can use something like this to avoid false warnings:
/* global $, alert, confirm, initParams */
/* jslint browser:true */
$(document).ready(function () {
alert(initParams.homepage);
});
By the way if you want to use routing in your Javascript code, you should take a look at the FOSJsRoutingBundle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With