Skip to content

Instantly share code, notes, and snippets.

@egulhan
Last active May 29, 2021 01:26
Show Gist options
  • Save egulhan/8147207 to your computer and use it in GitHub Desktop.
Save egulhan/8147207 to your computer and use it in GitHub Desktop.
Usage of ajax button in CButtonColumn in Yii Framework.
<?php
...
array(
'class'=>'CButtonColumn',
'template'=>'{confirm}{delete}',
//'template'=>'{confirm}',
'deleteButtonUrl'=>'Yii::app()->createUrl("/account/disabledAccounts",array("op"=>"delete","id"=>$data["id"]))',
'deleteButtonLabel'=>Yii::t('common','Cancel request'),
'deleteConfirmation'=>Yii::t('warnings','The account will be accessable by this operation. Are you sure you want to do this?'),
'buttons'=>array(
'confirm'=>array(
'label'=>Yii::t('common','Confirm'),
'url'=>'Yii::app()->createUrl("/account/disabledAccounts",array("op"=>"confirm","id"=>$data["id"]))',
'options'=>array('class'=>'confirm-btn btn btn-mini btn-primary'),
'click'=>"function(){
if(!confirm('".Yii::t('warnings','The account will be deleted by this operation. Are you sure you want to do this?')."')) return false;
$.fn.yiiGridView.update('disabled-accounts-grid', {
type:'GET',
url:$(this).attr('href'),
success:function(text,status) {
$.fn.yiiGridView.update('disabled-accounts-grid');
}
});
return false;
}",
),
),
),
...
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment