Skip to content

Instantly share code, notes, and snippets.

Created October 23, 2010 15:10
Show Gist options
  • Save anonymous/642312 to your computer and use it in GitHub Desktop.
Save anonymous/642312 to your computer and use it in GitHub Desktop.
//Delete
// Parameters:
//
$(function(){
var active=false;
$('.delete').live('click',function(e){
var ths=$(this);
var id=ths.closest('.item').attr('tid');
if(confirm('Are you sure?')){
startTip('Deleting...');
if(!active){
active=true;
$.ajax({
'type':"POST",
'url':'/x/delete/'+id,
'dataType':'json',
'success':function(d){
active=false;
if(d&&d.success){
endTip('Deleted!');
ths.closest('.item').remove();
}else if(d&&d.info){
errorEndTip(d.info);
}else{
errorEndTip('Oops! Unknown Error!');
}
},
'error':function(){active=false;}
});
}//if(!active){
}
e.preventDefault();return false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment