2014-03-13 24 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