1

その場でDOMに追加されたテーブル行にAJAX呼び出しを介してコンテンツをロードしています。コールバック関数で日付ピッカー機能を呼び出していますが、カレンダーは正常に表示されます。ただし、日付をクリックすると、エラーが表示されます: 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 クラスの削除、datepicker への参照の削除などを試みましたが、何も機能していません。助けてくれてありがとう!

4

2 に答える 2

5

I had the same error, which was because I had two datepickers input fields with the same id, one setup during runtime and the other through ajax. Gave them a unique id and it all worked

于 2010-04-22T10:18:47.030 に答える
0

前の行を消去する一環として、datepicker('destroy') を呼び出してみてください (remove() 呼び出しの前に実行してください)。

$("#tempEditRow .datepicker").datepicker('destroy');
$("#tempEditRow").remove();
于 2010-03-25T00:15:31.000 に答える