Reputation: 536
OK, this is frustrating.
All I simply want to do is reload the page after a CGridView Delete action. As the Delete is performed VIA Ajax, I cannot seem to reload the page.
I need to do this as I have other data on the page that is dependant on the data that I am deleting.
I have tried in the view
'class'=>'CButtonColumn',
'header'=>'Delete',
'template'=>'{delete}',
'buttons'=>array(
'delete'=>array(
'success'=>'function(){
window.location = location.href;
}',
),
),
Also in the delete controller as well
echo CHtml::script("
window.location.reload();
");
Yii::app()->end();
Any help appreciated.
Regards
Upvotes: 1
Views: 1349
Reputation: 1390
You can use afterDelete parameter (attribute) which exists in CButtonColumn
class:
'class'=>'CButtonColumn',
'header'=>'Delete',
'template'=>'{delete}',
'afterDelete'=>'function(link,success,data){
if(success) { // if ajax call was successful !!!
if(data == SUCCESS_TEXT) { // SUCCESS_TEXT the text which you output in your delete action on success
window.location.reload();
} else {
alert("Error! not deleted.");
}
} else {
alert("Error! delete request failed, see console for mor info");
console.log(data);
}
}',
Upvotes: 2