我正在回帖以使用 ajax 获取部分视图。我正在使用以下代码。
<script type ="text/javascript" >
$('#Retrieve').click(function () {
$('form').get(0).setAttribute('action', 'Search');
// $('form').submit();
var formSubmit = $('form');
var datTab;
$.ajax({
url: "/AuthorityGrid/Search",
type: "POST",
data: formSubmit.serialize(),
success: function (data) {
datTab = data;
},
complete: function () {
$('#DivSearchGrid').html(datTab);
}
})
return false;
});
</script>
控制器中的 action 方法返回一个带有新值的网格。我的问题是,在 ajx 调用完成后,我页面中的其他 jquery 事件停止工作。事件代码
<script type="text/javascript">
$(function () {
//$('th[scope|="col"]').resizable();
$("#resultGrid > tbody").selectable({
selected: function (event, ui) {
if (ui.selected.cells != null) {
var strAmount = ui.selected.cells(6).innerText;
var Amount = strAmount.replace(/,/gi, "");
var keyValue = "AuthorityLevel1=" + ui.selected.cells(11).innerText + ",AuthorityLevel2=" + ui.selected.cells(12).innerText + ",TcmAccount=" + ui.selected.cells(2).innerText + ",TcmType=" + ui.selected.cells(10).innerText + ",Rating=" + ui.selected.cells(5).innerText + ",Amount=" + Amount + ",AuthorityGridKey=" + ui.selected.cells(9).innerText + ",CagName=" + ui.selected.cells(3).innerText
var keyValModify = ui.selected.cells(11).innerText + "," + ui.selected.cells(10).innerText + "," + ui.selected.cells(12).innerText + "," + ui.selected.cells(5).innerText + "," + ui.selected.cells(2).innerText + "," + Amount + "," + ui.selected.cells(3).innerText + "," + ui.selected.cells(9).innerText
$('#CancelViewParam').val(keyValue);
$('#ModifyViewParam').val(keyValModify);
}
}
});
});
</script>
此函数从网格中选择一行并将所选值放入隐藏字段中。
在此功能的 ajax call.code 之后,打开弹出窗口的功能也不起作用。
$(function () {
$("#DivSearch").dialog({ autoOpen: false, height: "600", width: "600", dialogClass: "myRatingHelp", modal: true });
$('#bRatingHelperDivSearch').live('click',function () { $('#DivSearch').dialog('open'); });
$('#DivSearchRating_bOk').click(function () {
$("#InputAuthorityGridSearch_Rating").val($("#hidRating").val());
$("#DivSearch").dialog('close');
});
$('#DivSearchRating_bCancel').click(function () {
$("#DivSearch").dialog('close');
});
});
这些函数在 ajax 调用之前运行良好,但在进行 ajax 调用后都停止工作。我坚持这一点。请帮我。