CakePHP删除确认

Nez*_*zir 1 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>
Run Code Online (Sandbox Code Playgroud)

这会产生 html:

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

正如你所看到的,这会产生错误的 Html。

如何解决这个问题?

已修复:问题出在反斜杠“你确定吗?”,只需删除 \,这效果很好“你确定吗?”

sab*_*bin 5

尝试这个

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