簡體   English   中英

jQuery UI日歷在Ajax加載對話框中

[英]Jquery UI calendar in ajax loaded dialog

我的鏈接與onclick =“ open_dialog”一起打開了jQuery UI對話框。 它使用ajax加載其內容,並且該內容使用ajax加載另一個內容test2.php,其輸入標簽具有class =“ calendar”。 問題是,如果我單擊輸入,它將不會顯示任何日歷。 也許有人知道為什么嗎?

function open_dialog() {
    var url = 'test.php'; 
    var dialog;
    if ($('#test').length) {
        dialog = $('#test');
    } else {
        dialog = $('<div id="test" class="type_' + type + '" style="display:hidden;"></div>').appendTo('body');
    }
    dialog.load(
        url, 
        {},
        function (responseText, textStatus, XMLHttpRequest) {
            dialog.dialog({
                open: function(event, ui) {
                    $('.calendar').datepicker();
                }
            });
        }
    );
    return false;
}

抱歉,但是我找到了答案:我不得不在第二個ajax調用中調用日歷,如下所示:

$('#content_in_test_dialog').load(
    'test2.php', 
    function(response, status, xhr) {
        $('.calendar').datepicker();
    }
);

起初您應該找到問題所在? 1)首先添加alert('first line of open_dialog function'); 並檢查是否致電。 2)第二個檢查是日歷將自己的html內容添加到html頁面。 可能是它添加了自我內容,但是某些CSS樣式將其隱藏了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM