2011-01-06 64 views
0

我有一個的onclick =「OPEN_DIALOG」這將打開jQuery UI的對話環節。它用ajax加載它的內容,並且該內容用帶有class =「calendar」的輸入標籤的ajax加載另一個內容test2.php。問題是,如果我點擊輸入它不會顯示任何日曆。也許有人知道爲什麼?在阿賈克斯jQuery UI的日曆加載對話框

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; 
} 

回答

1

很抱歉,但我找到了答案: 我不得不打電話像這樣在第二Ajax調用日曆:

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

起初應該找到問題所在? 1)先加alert('first line of open_dialog function');,並檢查是否打電話。 2)第二次檢查是日曆添加了自己的html內容到html頁面。可能會添加自己的內容,但一些CSS風格隱藏它。