在我的网站中,我使用 CHtml::ajaxLink 它对我来说工作正常并删除我需要的内容 但我想用这个选项显示 javascript 确认消息任何人都可以帮助我
<?php
echo CHtml::ajaxLink('X',Yii::app()->createUrl('admin/deleteimg'),
array(
'type'=>'POST',
'data'=> 'js:{"data":'.$img->id.'}',
'success'=>'js:function(string){ document.getElementById("'.$img->id.'").remove(); }'
),array('class'=>'btn btn-danger small-btn'));
?>
最佳答案
您可以在htmlOptions
数组中添加确认。看看:
<?php
echo CHtml::ajaxLink('X',Yii::app()->createUrl('admin/deleteimg'),
array(
'type'=>'POST',
'data'=> 'js:{"data":'.$img->id.'}',
'success'=>'js:function(string){ document.getElementById("'.$img->id.'").remove(); }'
),array(
'class'=>'btn btn-danger small-btn',
'confirm'=>'Are you sure?' //Confirmation
));
?>
关于php - Yii CHtml::ajaxLink 确认删除时的 javascript 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25959042/