我通過AJAX調用將內容加載到添加到DOM上的錶行中。我在回調函數中調用日期選擇器功能,日曆顯示正常。但是,當我點擊日期時,出現錯誤:inst爲空。這裏是我的代碼:當通過AJAX加載時,jQuery datepicker返回「inst is null」錯誤
$(document).ready(function() {
$(".edit").live("click", function() {
//Delete previously loaded edit row
$("#tempEditRow").remove();
//Get the record id of the row to be edited
var recordID = $(this).parent("td").parent("tr").attr("id");
//Add the new row to the document
$(this).parent("td").parent("tr").after("<tr id=\"tempEditRow\"><td id=\"tempEditCell\" colspan=\"100\"></td></tr>")
//Get a reference to the new row
var container = $("#tempEditCell");
//Populate the container
populateContainer("/wpm/includes/ajax_editApplication.cfm?id=" + recordID, container);
});
});
function populateContainer(ajaxUrl, container) {
//Populate the container
$.ajax({
url: ajaxUrl,
cache: false,
success: function(html){
$(container).html(html);
$('.datepicker').datepicker();
}
});
}
我試着刪除hasDatepicker類,刪除任何引用到日期選擇器等,但沒有什麼工作。預先感謝您的幫助!
這是問題...我在頁面中有重複的ID,與運行時加載的情況相同,另一種情況是通過ajax。 – Robert 2010-05-19 14:39:23
很高興你把它排序 – andyface 2010-05-20 10:45:54