Skip to content

Instantly share code, notes, and snippets.

@RelativeMedia
Created June 11, 2012 05:25
Show Gist options
  • Save RelativeMedia/3f26b0eea31338005f78 to your computer and use it in GitHub Desktop.
Save RelativeMedia/3f26b0eea31338005f78 to your computer and use it in GitHub Desktop.
$('.confirm-delete').click(function(){
oTable = $('table.datatable').dataTable();
if( confirm('Are You Sure You Want To Delete This Item?') ){
$.ajax({
url: $(this).attr('href'),
type: "POST",
dataType: "json",
success: function(r, s, xhr){
console.log(xhr);
setTimeout(function(){
var pos = $('table.datatable').closest("tr").get(0);
var aPos = oTable.fnGetPosition( pos );
oTable.fnDeleteRow( aPos );
}, 400);
},
error: function(s, d, xhr){
console.log(s);
console.log(d);
console.log(xhr);
console.log('there was an error');
}
});
return false;
}else{
return false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment