0

我在 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'));
    }

没有错误,但它只是在单击时不会删除项目。有人知道这里发生了什么吗?

4

0 回答 0