我正在使用一些非常簡單的JQuery Ajax加載,除了一個項目以外,它在任何地方都可以愉快地工作。該區域在頁面完成加載後加載,然後將所有刪除鏈接綁定到ajaxform提交。這將工作100%,直到使用刪除按鈕。內容重新加載正確,但重新綁定似乎在完全加載之前發生,因爲它不會重新綁定刪除鏈接。檢查元素集合的大小表明它仍然包含已刪除的項目(例如,只有4個時顯示5)。Jquery Ajax在加載完成之前加載回調觸發器
下面是代碼:
function AjaxLoadCostActivities(CallBack) {
ShowAjaxProgressIndicator(id_CostActivitiesListing);
id_CostActivitiesListing.load(url_LoadCostActivities, CallBack);
}
function PrepareCostActivitiesForm() {
// Submits the form for the delete image button
$("a.CostActivityDeleteImage").click(function() {
if (confirm("Are you sure you want to delete this record?")) {
$(this).parent().ajaxSubmit({
target: id_CostActivitiesListing,
success: AjaxLoadCostActivities(PrepareCostActivitiesForm)
});
return false;
}
return false;
});
}
// This is the call that loads the content on page load
// CostActivitiesStartup is just a function that does some unrelated stuff but also
// calls PrepareCostActivitiesForm to prepare the delete forms.
AjaxLoadCostActivities(CostActivitiesStartup);
ShowAjaxProgressIndicator只是顯示加載圖像。 –