0

我有一个锂 Html 帮助链接

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

单击此链接时,我希望显示一个确认框,但我在文档中看不到任何允许我执行此操作的内容。

这可能吗?

4

2 回答 2

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?")'); ?>
于 2012-03-09T14:23:18.063 回答
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>
于 2012-03-10T09:40:45.823 回答