Bootstrap确认数据确认未执行功能

Pon*_*ngr 3 javascript twitter-bootstrap

我正在尝试删除确认执行删除当前id数据的函数.

我收到此错误:

未捕获的TypeError:无法读取未定义的属性"call"

在这部分 bootstrap-confirmation.js

return function() {
  context[func].call(this);
};
Run Code Online (Sandbox Code Playgroud)

这是我的按钮代码

<button class="btn btn-danger" data-toggle="confirmation" 
data-    btn-ok-    class="btn-danger" data-btn-cancel-icon="glyphicon 
glyphicon-ban-circle" data-btn-cancel-class="btn-default" 
data-popout="true" data-singleton="true" data-on-confirm="goDel(id)">
Eliminar</button>
Run Code Online (Sandbox Code Playgroud)

这是我的Javascript

<script type="text/javascript">
function goDel(id)
{
location.href="./delete/" + id;
}
</script>
Run Code Online (Sandbox Code Playgroud)

这是我的删除控制器

public function delete($id) {
    $clientes = new Clientes();
    $codcta = new Codcta();
    $this -> codcta = $codcta -> find();
    $codciu = new Codciu();
    $this -> codciu = $codciu -> find();        
    $clientes = new clientes();
    if ($clientes->delete((int)$id)) {
            Flash::valid('El registro se ha eliminado correctamente');
    }else{
            Flash::error('Falló Operación'); 
    }
    return Redirect::to();
}
Run Code Online (Sandbox Code Playgroud)

小智 7

在按钮中更改此内容:

data-on-confirm="goDel"
Run Code Online (Sandbox Code Playgroud)

并添加这个:

data-id="YOUR-ID-HERE"
Run Code Online (Sandbox Code Playgroud)

在你的javascript函数中:

function goDel()
{
    var id = $(this)[0].getAttribute('data-id');
    location.href="./delete/" + id;
}
Run Code Online (Sandbox Code Playgroud)

祝好运!