user4034319
user4034319

Reputation:

symfony call controller action in javascript with id

Is it possible to call the controller action in javascript. I tried in the following way but it wont work

 $('#members').html({%render(controller('AmvMembersBundle:Pages:EditMembers'))%});  

Upvotes: 1

Views: 1673

Answers (2)

lsouza
lsouza

Reputation: 2488

A better solution in this case is to put the render funciton inside a div, then control its visibility with JS.

<div id="members">
    <div class="edit hidden">
        {% render(controller('AmvMembersBundle:Pages:EditMembers')) %}
    </div>
</div>

<script>
    $('#members').find('.edit').removeClass('hidden');
</script>

Although, if you need this to be dynamically called, you should load the controller via AJAX.

Upvotes: 0

Sergei Gorjunov
Sergei Gorjunov

Reputation: 1799

Replace {% %} with {{ }}. Then it should show content.

Upvotes: 1

Related Questions