CakePHP删除确认

时间:2014-03-19 22:59:18

标签: javascript php cakephp confirmation

我有Cake PHP删除javascript确认对话框的问题。

我正在使用此代码:

<td><?php echo $this->Html->link('Delete',
                                        array('controller' => 'RealEstate', 'action' => 'delete',$r['RealEstate']['id']),
                                        array('onclick'=>'return confirm(\"Are you sure?\");'))?> </td>

并生成html:

<td><a onclick='return confirm(\"Are you sure?\");' href="/cake1/RealEstate/delete/65">Delete</a> </td>

你可以看到这会产生错误的Html。

如何解决这个问题?

FIXED: 问题是反斜杠“你确定吗?”,只是删除了\并且这很有效“你确定吗?”

3 个答案:

答案 0 :(得分:3)

试试这个

 echo $this->Form->postLink(__('Delete'), array(
                               'controller'=>'RealEstate',
                               'action' => 'delete',
                                $r['RealEstate']['id']),
                                null, 
                                __('Are you sure you want to delete # %s?', 
                                $r['RealEstate']['id'])
 ); 

答案 1 :(得分:3)

试试这个

<?php 
     echo $this->Html->link('',array('controller'=>'Mycont','action'=>'deletepic',$id),
          array('confirm'=>'Are you sure you want to delete the image?'));
?>

答案 2 :(得分:0)

修复:问题出现在反斜杠中\“你确定吗?\”,只是删除\并且效果很好“你确定吗?”