2014-03-13 23 views
-1

我創建了一個彈出式的確定和取消按鈕之前行刪除gridview使用jquery但無法刪除時,我按下了確定按鈕。下面是代碼我用過,請大家幫我刪除不工作是按鈕的jQuery彈出

<script type="text/javascript"> 
     <!-- Load --> 
    $(function() { 
     $("#message").html("Are you sure you want to delete User?"); 
     $("#dialog").dialog({ 
      title: "Delete Confirmation", 
      buttons: { 
       Ok: function() { 

       }, 
       Cancel: function() { 
        $(this).dialog('close'); 
       } 
      }, 
      modal: true, 
      visibility: hidden 

     }); 
    }); 
    //<!-- Log Message Popup --> 
    function UserDel() { 
     $("#message").html("Are you sure you want to delete User?"); 
     $("#dialog").dialog({ 
      title: "Delete Confirmation", 
      buttons: { 
       Ok: function() { 
         return true; 
       }, 
       Cancel: function() { 
        $(this).dialog('close'); 
        return false; 
       } 
      }, 
      modal: true 
     }); 
    } 

    </script> 
+0

嘗試'的OnClientClick =「返回確認(‘你確定要刪除用戶?’);」' –

+0

其工作正常,當我使用返回確認();但我們在該確認消息中獲得瀏覽器URL,所以我想用jquery popup – sumanth

回答

0

編輯 比方說,而不是使用的onclick您識別由類刪除的行

<tr class="deletablerow">blah blah</tr> 

可刪除的行然後你的js代碼應爲:

$(function() { 
     $('.deletablerow').on('click',function() { 
     UserDel(jQuery(this)); 
     }); 

     function UserDel(element) { 
     $("#message").html("Are you sure you want to delete User?"); 
     $("#dialog").dialog({ 
      title: "Delete Confirmation", 
      buttons: { 
       Ok: function() { 
        element.remove(); 
        return true; 
       }, 
       Cancel: function() { 
        $(this).dialog('close'); 
        return false; 
       } 
      }, 
      modal: true 
     }); 
    } 
}); 
+0

我打電話給我的delete方法deleteUserRowClick()onClick =「DeleteUserRowClick」 我怎麼能在ok按鈕中調用 – sumanth