How javascript, jquery works in Symfony2

I am trying to understand how you are using jquery or other scripts in Symfony2. I read the asset documentation however it didn't help me much.

So I have a base.html.twig file to which I add the jquery library and my script file containing a simple script.

I add it like this:

{% block javascripts %}
    {# Le Javascript #}         
    {% javascripts 
        'bundles/mpFrontend/assets/js/jquery-1.11.2.min.js'         
        'Mp/ShopBundle/Resources/js/scripts.js'   
    %}
        <script src="{{ asset_url }}"></script>       
    {% endjavascripts %}

      

Now I have index.html.twig in which I extend base.html.twig .... Is that all I need? For me the script is not working, I need to somehow get it in index.html.twig too?

+3


source to share


1 answer


You messed up with the Asstic library and the Assets component. It is not the same. You must use the command:

php app/console assetic:dump

      



This command will compile your js file and place it in the correct location.

+1


source







All Articles