Search code examples
phpjavascriptlithium

Lithium: Show confirm box when link is clicked


I have a lithium Html helper link

<?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?


Solution

  • As provided by Dvir Volk this can be solved using the following:

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