2012-01-25 1 views
0

グリッドビューには、行を削除するためのasp image-buttonがあります。行が削除されている間、私はフェード効果を実装しました。それは正常に動作しています。私の問題はフェード効果が常に働くことです - ユーザーがOKをクリックしたかキャンセルしたかにかかわらず。フェード効果は、ユーザーが確認ボックスをクリックしたときにのみ必要です。ハマった。以下は私のフェード効果のコードです。JqueryのGridView行

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; 
      } 
     } 

私は関数内でクリックイベントを配置することはできません知っているが、私はremoveRow関数内でクリックされた行を取得する方法を知りません。

+0

imageにまだバインドされていない場合、removeRowはどのように呼び出されますか? – Malk

答えて

0

おかげアダム、その...行って代わりのqqueryクリックイベントの外に、私は

$(\"#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; 
     } 
    }); 

以下のようなクリックイベント内で、あなたの懸念を示すためとにかくおかげでそれを置くかの条件のおかげでたくさん。