Hi, I have a doubt and it’s how to update a content that a I have on a $this->clips[‘sidebar’] I use that clip to show a list of tweets and the “owner” of the tweets can “hide” and “un-hide” those tweets I already do the “hiding” part, what I want is that when I click the “Hide” link the whole sidebar refreshes.
That’s my view code as you can see I have ‘update’=>’#hide-tweet’ but to be hones I don’t know ho to handle ajax very well I think that it has to do something with the ‘complete’ status but sincelery I don’t know how to use it I already can ‘hide’ and ‘un-hide’ the tweet all that I need is how to ‘refresh’ or ‘update’ the sidebar.
Thanks
<h1>Tweet Feed</h1>
<ul>
<?php $form=$this->beginWidget('CActiveForm', array('id'=>'hide-tweet',)); ?>
<?php $i=1; foreach($tweets as $tweet):?>
<div id="tw-<?php echo $i; ?>">
<div class="view">
<li class="entries"><?php echo '<b>'.$tweet->user->name.'</b> @'.$tweet->user->screen_name.' '.date("d M",strtotime($tweet->created_at)); ?></li><br/>
<li class="entries"><?php echo $tweet->text.'<br/>';?></li>
<br/><li class="entries">
<?php if(in_array($tweet->id_str, $db_tweet_id))
{
if($model->usr_id != Yii::app()->user->Id){echo "Show";}
else
{
echo CHtml::ajaxLink(
'Show',
array('tweet/show'),
array(
'update'=>'#hide-tweet',
'type'=>'POST',
'dataType'=>'json',
'data'=>array(
'Tweet'=>array(
'tw_tweet_id'=>$tweet->id_str,
'tw_author'=>$model->usr_id,
),
),
));
}
}
else
{
if($model->usr_id == Yii::app()->user->Id)
{
echo CHtml::ajaxLink(
'Hide',
array('tweet/hide'),
array(
'update'=>'#hide-tweet',
'type'=>'POST',
'dataType'=>'json',
'data'=>array(
'Tweet'=>array(
'tw_tweet_id'=>$tweet->id_str,
'tw_author'=>$model->usr_id,
),
),
));
}
}
?>
</li>
</div>
</div>
<?php $i++; endforeach; ?>
<?php $this->endWidget(); ?>
</ul>