Confidence
Confidence

Reputation: 2303

Symfony2 and Jquery UI-Tabs

I have page, i can contact directly without any problems.

http://www.mysite.com/app_dev.php/comments/22

the page shows a simple Text-form element and a row of comments for the thread 22...and i can submit a new comment without any problems

But when i put this page, in a tabs like this,

<div id="tabs">
<ul>
    <li><a href="#infotab">Information</a></li>
    <li><a href="{{ path('comment', { 'torrent_id': filedata.fid })  }}" >Comments</a>       </li>

</ul>

it shows the simple Form, but does not show the comments....so the routing does not seem to work properly.....any workaround on this?...and also filling the field with a comment does not work (it does not persist it to DB, without showing errors).

Upvotes: 2

Views: 798

Answers (1)

Asa Ayers
Asa Ayers

Reputation: 4894

jQuery tabs use AJAX to fetch the page. If that URL is returning full HTML that could be your problem. To avoid returning full HTML on an ajax request, I often have my templates use a conditional extension.

{% extends app.request.isXmlHttpRequest ? "MyBundle::ajax.html.twig" : "::base.html.twig" %}

MyBundle::ajax.html.twig is a very simple template that simply renders my body block inside a <div>. Using this method when you visit the page directly you get a full HTML page complete with stylesheets and javascript. An ajax request gets only the body and assumes the page loading it already has the CSS and javascript it needs.

Upvotes: 1

Related Questions