我通过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