首先,我已经尝试了所有可能的答案在这个网站,但没有为我工作。Javascript删除codeigniter中的确认框
我想在删除我的数据前弹出窗口确认。我用这个
<a href="<?php echo site_url('admin/barang/delete/'.$val->idBarang);?>" onclick="return confirm('Are you sure ?')">Delete</a>
也许你需要我的控制器
public function delete($id = 0) {
$id OR redirect(site_url('admin/barang'));
$this->barang_m->delete($id);
redirect(site_url('admin/barang'));
}
我的模型barang_m
public function __construct(){
parent::__construct();
parent::set_table('barang','idBarang');
}
public function delete($id = 0) {
if($data = parent::get($id)) {
parent::delete($id);
return true;
}
return false;
}
但是当我点击取消还是删除数据,甚至当我点击“X”来关闭确认窗口。我很沮丧,请帮助我。或者,也许你可以告诉我为什么会出现这个问题?
**我alrady试过这种可能的答案
Codeigniter when i click delete i want pop up notification if if click yes or not
jQuery delete confirmation box
Confirm box in CodeIgniter anchor link to delete record 和许多
请与你的代码共享一个jsfiddle或plunkr链接。 –
可能重复的[preventDefault()在标签](http://stackoverflow.com/questions/265478/preventdefault-on-an-a-tag) –