2012-05-13 27 views
2

我有一個JavaScript函數圖(),它繪製了一個動態圖,我想把它放在一個模態對話框中。 我寫了這個:如何使用JQuery UI在模態對話框內顯示JavaScript圖形?

function drawGraphinDialog(){ 
    $("body").append('<div id="graphdialog"></div>'); 
    $(document).ready(function(){ 
     $("#graphdialog").dialog({ 
        modal: true, 
        open: function{ 
             graph(); 
           },   
        height: 600, 
        width: 400, 
        title: 'This is your graph' 
        }); 
     return false; 
    }); 
} 

但模態對話框是空的。 我應該在哪裏放置函數graph()來正確地在圖中繪製它? 感謝您的幫助!

編輯:圖形已經與這個庫http://www.graphdracula.net/ ...所以如果我在html正文頁面中調用這個函數graph(),它會繪製這個圖形,我可以真正看到它。

+1

答案取決於'graph()'(或'Graph()' - 你在你的問題中都有拼寫)如何繪製圖形。 – jimw

回答

0
function drawGraphinDialog(){ 
    $("body").append('<div id="graphdialog"></div>'); 
    call graph() function and set its content to graphdialog div 
    $("#graphdialog").html(graph_content) 

$('#graphdialog').dialog({ 
     modal: true, 
     height: 600, 
        width: 400, 
        title: 'This is your graph' 
    }); 
}