繁体   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