Home >Backend Development >PHP Tutorial >yii?删除按钮问题

yii?删除按钮问题

WBOY
WBOYOriginal
2016-06-23 13:30:281131browse



Views->index.php:  'delete' => array        (             'label'=>'Delete Record',              'imageUrl'=>Yii::app()->request->baseUrl.'/images/list_del.gif',               url'=>'Yii::app()->createUrl("series/delete", array("id"=>$data->id,"menu"=>Yii::app()->controller->curmenu))',           ),Controller: public function actionDelete($id)    {        if($id==4) {            $model = $this->loadModel($id);            $model->delete();            if (!isset($_GET['ajax']))                $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));        }else{   /*echo("<script>alert(1);</script>");*/  //不会弹出错误信息框?//当id不等于4时,弹出一个错误信息  (  这部分未实现)        }    }


点击删除按钮时:
当id=4删除该数据
当id!=4在页面弹出一个框,提示用户信息


回复讨论(解决方案)

不懂,看你这样应该能弹出来啊

不懂,看你这样应该能弹出来啊



删除的时候,页面是没有刷新的
我本来打算用ajax,但是我办法获取删除按钮的名字


没有一个name的属性

Views->index.php:
  'delete' => array
        (
            'name'=>'deletename',  //根本没用
             'label'=>'Delete Record',
              'imageUrl'=>Yii::app()->request->baseUrl.'/images/list_del.gif',
               url'=>'Yii::app()->createUrl("series/delete", array("id"=>$data->id,"menu"=>Yii::app()->controller->curmenu))',
           ),


点了不刷新?

Views->index.php:
  'delete' => array
        (
            'name'=>'deletename',  //根本没用
             'htmlOptions'=>array('name'=>'deletename'),//这样呢
             'label'=>'Delete Record',
              'imageUrl'=>Yii::app()->request->baseUrl.'/images/list_del.gif',
               url'=>'Yii::app()->createUrl("series/delete", array("id"=>$data->id,"menu"=>Yii::app()->controller->curmenu))',
           ),


什么叫只有引用内容不能回复,csdn

还有一种办法,delete的时候加个判断,如果等于4,直接不会提示删除链接,并且在controller里面加个判断是否为4.

还有一种办法,delete的时候加个判断,如果等于4,直接不会提示删除链接,并且在controller里面加个判断是否为4.



我现在的问题是,如果不等于4,我要弹出一个框告诉用户,这是不能删除的.   弹框没法实现

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn