简体   繁体   English

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

[英]Lithium: Show confirm box when link is clicked

I have a lithium Html helper link 我有一个锂HTML助手链接

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

When this link is clicked I would like a confirm box to show up, but I can't see anything in the documentation that would allow me to do this. 单击此链接后,我希望显示一个确认框,但是我在文档中看不到任何允许我执行此操作的内容。

Is this possible? 这可能吗?

如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?")'); ?>

I would use jquery to add an event to it. 我将使用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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM