在我的情况下,我有一个jquery ui对话框,当我在插入数据后关闭对话框而不提交几秒钟并且在其他情况下工作正常时保留文本框中的旧值。任何建议??
$("#btnAddRole").click(function ()
{
console.log(RoleAddPostBackURL);
var divDetail = $("#addRolePlace");// div to open in dialog
$.ajax({
type: "GET",
url: RoleAddPostBackURL,
//traditional: true,
contentType: "application/html; charset=utf-8",
//data: { "id": id },
datatype: "html",
success: function (data)
{
divDetail.html(data);
//alert(divDetail.html());
},
error: function () {
alert("Error: Dynamic content load failed.");
}
});
var winW = $(window).width() - 720;
//code to open div in dialog
divDetail.dialog(
{
autoOpen: true, //true => false
position: {
position: [0,28]
},
height: "auto",
width: winW,
resizable: false,
//position: [0, 28],
resizable: false,
title: 'Add New Role',
modal: true,
//show:
//{ effect: "blind", duration: 1000 },
open: function () {
divDetail.load();//This will load div
divDetail.css('overflow', 'hidden');
},
buttons:
[
{
text: "Close",
"class": 'btn-success',
click: function () {
$(this).dialog("close");
}
}
]
});
});
HTML:
<div id="addRolePlace">
</div>
<script src="~/Scripts/Role.js"></script>
答案 0 :(得分:1)
在关闭时尝试此操作:function()
close: function () {
$('#RoleName').val("");
}
希望这会有所帮助。