I'm trying to make a delete confirmation execute a function that deletes the current id data.
I am getting this error:
Uncaught TypeError: Cannot read property 'call' of undefined
in this part of the bootstrap-confirmation.js
return function() {
context[func].call(this);
};
this is my button code
<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>
this is my Javascript
<script type="text/javascript">
function goDel(id)
{
location.href="./delete/" + id;
}
</script>
this is my delete controller
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();
}
Change this in your button:
data-on-confirm="goDel"
and add this:
data-id="YOUR-ID-HERE"
in your javascript function:
function goDel()
{
var id = $(this)[0].getAttribute('data-id');
location.href="./delete/" + id;
}
Good Luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With