i want my notification to be set 0 when the dropdown is clicked. after clicking dropdown, the value in <span id="notif"> must also change into 0.
script below is my progress so far. debugging by using chrome, i found error message "Uncought SyntaxError : Unexpected Token }".
please help if any of you know how to solve this problem. thank you
this view inside theme folder
<li class="dropdown" style="text-align: left"
onclick=" <?php
echo CHtml::ajax(array(
'id' =>'updatestatus',
'type' => 'POST',
'url' => Yii::app()->createUrl('tx/notification/updatestatus'),
'update' => '#notif',
));
?>"
>
<a href="#" data-toggle="dropdown" class="dropdown-toggle" >
<span class="glyphicon glyphicon-bell"></span>
<span id="notif" class="badge">
<?php
echo $unreadNotif;
?>
</span>
<b class="caret"></b>
</a>
...
...
</li>
notification controller
...
...
public function filters() {
return array( 'rights', );
}
public function allowedActions() {
return 'UpdateStatus';
}
public function actionUpdateStatus(){
if(isset($_POST['updatestatus'])){
$notifications = Notification::model()->findAllByAttributes(array('read_status'=>false,'notify_to'=>Yii::app()->user->id));
foreach ($notifications as $notify) {
$notify->read_status=1;
$notify->save();
}
echo '0';
Yii::app()->end();
}
}
...
...