I have a custom delete button, all i want is some sort of confirmation before delete action takes place.. I have tried multiple ways of doing so with no success so far.
here is my code, I am using CArrayDataProvider thus had to create a template for delete button.
array(
'class' => 'CButtonColumn',
'template' => '{delete}{reset}',
'deleteConfirmation'=>"js:'Are You Sure?'",
'afterDelete'=>'function(link,success,data){ if(success) alert("Delete completed successfully"); }',
'buttons' => array(
'delete' => array(
'label'=> 'Remove this device',
'imageUrl'=> Yii::app()->request->baseUrl.'/img/delete.png',
'url' => 'Yii::app()->controller->createUrl("controller/action", array("trace_id"=>$data["trace_id"], "mac"=>$data["mac"]))',
'click'=><<<EOD
function(){
confirm('Are you sure?')
}EOD
),
NOW I SHOW YOU WHAT I DO IN MY CODE FOR THE THING YOU WANT TO DO
I have copy paste code. so it will be extra. When some one clicks on "Status" button. It will open bootstrap modal. and ask for a confirmation. While executing this i have created a form with action and some fields. and in that modal i have proceed button. on proceed button click the form will be submitted. and on close the form will be made empty. the form will be display none form. and will have all the fields hidden.. I know it is more complex then urs... but I do it with post... BUT YOU CAN ASSIGN YOUR HREF TO POST BUTTON LINK IN THIS FUNCTION AND ON CLICK ON THAT IT WILL BE REDIRECTED