[英]Adding JS To Codeigniter Links - Simple OnClick
我正在尝试将一个简单的Javascript代码段写入Codeigniter链接。 我正在使用该链接删除仪表板中所需的帖子。 虽然我想学习它,但我对JS一无所知。
码
$js = 'onClick = "alert("Are you sure")"';
$this->table->set_heading('Date', 'Title', 'Delete', 'Update');
foreach($records as $row){
$row->title = ucwords($row->title);
$this->table->add_row($row->date,
$row->title = ucwords($row->title),
anchor("main/delete/$row->id", $row->id, $js), //this is the link in question
anchor("main/fill_form/$row->id", $row->id)
);
}
$table = $this->table->generate();
echo $table;
我的问题是如何为链接($ js)编写JS。 我想使用确认声明(是或否)。 我完全迷失了JS,以防止意外删除
谢谢
以下是使用CodeIgniter锚点函数执行此操作的方法:
echo anchor('delete/something', 'Delete', array('onClick' => "return confirm('Are you sure you want to delete?')"));
单击链接时会显示一个确认框。 如果用户确认,则遵循链接。 如果用户取消,则不采取任何措施。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.