I have a gridview which has an asp image-button for deleting a row. I implemented a fade effect while the row is being deleted; that's working fine. My problem is the fade effect works always - whether the user has clicked ok or cancel. I want the fade effect only when user has clicked ok for the confirm box. I am stuck. Below is my code for the fade effect.
function removeRow() {
if (confirm("Are you sure you want to delete this comment?")) {
$("#dnn_BlogCommentManager1_grdBlogComments td: input[type='image']").click(function () {
$tr = $(this).closest("tr");
if ($(this).hasClass("imgDelete")) {
$tr.css("background-color", "red");
$tr.fadeOut(500, function () { $tr.remove() });
}
});
}
else {
return false;
}
}
I know I cannot place the click event inside the function, but I don't know how I can get the clicked row inside the removeRow
function.
Thanks Adam, its done instead of the if condition outside the qquery click event, i put it inside the click event like below
$(\"#dnn_BlogCommentManager1_grdBlogComments td: input[class='imgDelete']\").click(function () {
$tr = $(this).closest(\"tr\");
if (confirm(\"Are you sure you want to delete this comment?\")) {
if ($(this).hasClass(\"imgDelete\")) {
$tr.css(\"background-color\", \"red\");
$tr.fadeOut(500, function () { $tr.remove() });
}
}
else {
return false;
}
});
Anyways thanks for showing your concern... thanks a lot.