Lithium:单击链接时显示确认框

时间:2012-03-09 11:16:51

标签: php javascript lithium

我有一个锂Html帮助链接

<?php echo $this->html->link('Delete', array('action' => 'delete', 'args' => $id); ?>

点击此链接时,我想显示一个确认框,但我在文档中看不到任何可以让我这样做的内容。

这可能吗?

2 个答案:

答案 0 :(得分:1)

由Dvir Volk提供,可以使用以下方法解决:

<?php echo $this->html->link('Delete', array('action' => 'delete', 'args' => $id), array('onclick', 'return confirm("Are you sure you wish to delete this item?")'); ?>

答案 1 :(得分:0)

我会用jquery向它添加一个事件。

<?php echo $this->html->link (
    'Delete', 
    array(
        'action' => 'delete', 
        'args' => $id, 
        'class' => 'delete'
    )
); ?>

<script>
    $('a.delete').click(function(){
        confirm("Are you sure you wish to delete this item?");
    });
</script>