I have a problem in using Ajax and ClistView.
I have 2 posts , each one has comments, the first one has 3 comments, the second one , one comment.
Post A
Link to Comments(3)
Post B
Link to Comments(1)
When I click on Link to Comments(3), I got the following, as expected
Post A
Comment 1
Comment 2
Comment 3
Post B
Link to Comments(1)
But when I click on comments(1), I got
Post A
Comment 1 of post B
Post B
So the comment of Post B displays under the post A.
How can I solve the problem ?
The code of the Ajax link is the following
<?php
echo CHtml::ajaxLink(
'Test request',
array($url_replace),
array(
'update'=>'#req_res_loading',
'beforeSend' => 'function() {
$("#maindiv").addClass("loading");
}',
'complete' => 'function() {
$("#maindiv").removeClass("loading");
}',
)
);
echo '<div id="req_res_loading">...</div>';
?>
and the comments are called through the Clistview command
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_comment',
'template'=>"{items}
{pager}",
)); ?>
my _comments view contains the following
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_comment',
'template'=>"{items}
{pager}",
)); ?>
and my _comment view contains the following
<div class="comment">
<div class="content">
<?php
$this->beginWidget('CMarkdown', array('purifyOutput'=>true));
echo $data->content;
$this->endWidget();
?>
</div>
</div>
and the post view is renderPartial with this code
<div class="post">
<div class="title">
<?php echo CHtml::link(CHtml::encode($data->title), $data->url); ?>
</div>
<div class="author">
posted by <?php echo $data->author->username . ' on ' . date('F j, Y',$data->create_time); ?>
</div>
<div class="content">
<?php
$this->beginWidget('CMarkdown', array('purifyOutput'=>true));
echo $data->content;
$this->endWidget();
?>
</div>
Thank you in advance for your help