Skip to content

Instantly share code, notes, and snippets.

@elijahmanor
Created August 4, 2011 04:25
Show Gist options
  • Save elijahmanor/1124506 to your computer and use it in GitHub Desktop.
Save elijahmanor/1124506 to your computer and use it in GitHub Desktop.
Find the jQuery Bug #1: Timing - Problem
zebraTable();
$( ".delete" ).bind( "click", function() {
var $this = $( this ),
$row = $this.closest( "tr" ),
rowId = $row.attr( "id" );
$.ajax({
url: "/Contact/Delete/" + rowId,
type: "POST",
success: function( data, textStatus, jqXHR ) {
if ( data.status === "success" ) {
$row.hide( 500, function() {
$row.remove();
});
} else {
console.log( data.message );
}
},
error: function( jqXHR, textStatus, errorThrown ) {
console.log( "error", textStatus );
},
complete: function( jqXHR, textStatus ) {
zebraTable();
}
});
});
function zebraTable() {
$( "tr" ).removeClass( "odd" )
.filter( ":odd" ).addClass( "odd" );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment