我在CListView中有一个删除功能,它曾经工作过,但现在不再使用了。
在CListView中我有:
echo CHtml::link('<img src="images/delete.png" />',
$this->createUrl('persoon/delete',array('id'=>$data->id)),
array(// for htmlOptions
'onclick'=>' {'.CHtml::ajax( array(
'beforeSend'=>'js:function(){if(confirm("Are you sure you want to delete?"))return true;else return false;}',
'success'=>"js:function(html){ alert('removed'); }"
)).
'return false;}',// returning false prevents the default navigation to another url on a new page
'class'=>'delete-icon')
);
控制器未经编辑:
public function actionDelete($id)
{
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(array('index'));
}
没有错误,但是单击时它不会删除项目。有人知道这里发生了什么吗?