2

Is it possible to add a javascript block in a Sonata Block View like this ?

{% extends sonata_block.templates.block_base %}

{% block block %}

     <!-- html -->

{% endblock %}

{% block javascripts %}

    // javascript code

{% endblock %}

I couldn't make it works in this way as javascript block doesn't exist in template block base but present in my layout.

emilie zawadzki
  • 2,035
  • 1
  • 18
  • 25
  • 1
    Have you tried to put Javascript directly, without `{% block javascripts %}`? – A.L Apr 27 '15 at 08:32
  • Yes but this isn't what I want. I want to get the parent() of the javascript block of my layout, then add dynamically my js from the block view. Sorry, I wasn't accurate about getting parent(). – emilie zawadzki Apr 27 '15 at 10:16
  • Unfortunately this isn't possible.. Take a look here: http://stackoverflow.com/questions/12682968/adding-js-and-css-cleanly-from-included-twig-templates – 11mb May 05 '15 at 15:21

0 Answers0