dsnrixf6765 2015-09-04 09:09
浏览 31
已采纳

Ajii删除yii

How can I put a ajax delete button for delete the comment by the posted user?
_form

 echo '<div><h3><b><u>Comments</u></b></h3></div>';

 $commentList = Comments::model()->findAllByAttributes(array('offereventid'=>$id));
     foreach($commentList as $Listdata2)
     {   
        $usercomment = $Listdata2['comment']; 
        $usercommentid = $Listdata2['id'];          
        $usercomtname = $Listdata2['name'];         
        $usercommentmail = $Listdata2['email'];      
        echo '<div><span class="name1">'.$usercomtname.':</span> '.'<span class ="email1">'.'['.$usercommentmail.']'.'</span>'.'</div>';            
        echo '<div class = "cmnts" >'.'"'.$usercomment.'"'.'['.$usercommentid.']'.'</div>';
        // echo CHtml::ajaxSubmitButton('Delete ', array('delete', 'id'=>$usercommentid)); 

        echo '<hr>';    
     } 

please help me with it. I tried lot of methods but when i tried any user can delete the comment of any user.

  • 写回答

2条回答 默认 最新

  • dq8081 2015-09-04 15:21
    关注

    I got the solution for the problem

    echo CHtml::ajaxButton(
       'Delete',
       CHtml::normalizeUrl(array(
           'Comments/del/id/' . $usercommentid, 
           'render' => true
       )),
       array(
           'dataType' => 'json',
           'type' => 'post',
           'success' => 'function(data) {
                $("#name_"+data).hide();
            }',
    
       ),
       array('id' => $usercommentid, 'class' => 'btn btn-success')
    );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题