我在使用jquery在gridview中删除行之前创建了一个带有ok和取消按钮的警报消息,但是当我按下ok按钮时无法删除。以下是我用的代码,请帮帮我
<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 :(得分: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
});
}
});
答案 1 :(得分:0)