2011-07-14 111 views
0

我想打開iframe中的鏈接對話框,但是我不能讓它彈出對話框 有人知道原因嗎?jQuery UI對話框 - 如何從iframe中的鏈接打開對話框

我在HTML中的iFrame <iframe src="Add_Reviewer.html" width="100%" name="test" frameborder="0" scrolling="auto" height="100%"></iframe>

我在Add_Reviewer.html鏈接 <a href="#" id="advance_add">Advance Add</a>

我的jQuery代碼

var $advance_add = $('<div></div>') 
    .html('<iframe src="Advance_Add.html" width="100%" name="test" frameborder="0" scrolling="auto" height="100%">') 
    .dialog({ 
     autoOpen: false, 
     bgiframe: true, 
     width:650, 
     minWidth: 650, 
     height: 550, 
     closeOnEscape:true, 
     modal:true, 
     title: 'Addvance Add', 
     buttons : { 

        "Close" : function() { 
            $(this).dialog("close"); 
              } 
     } 
    }); 

$("#advance_add").click(function(e) { 

    e.preventDefault();  
$advance_add.dialog('open'); 

}); 
+0

你正在加載jQuery + jQuery iFrame或父文件中的UI? – polarblau

回答

2

我使用這個代碼:

$("#advance_add").click(function() { 
    $('<iframe src="Advance_Add.html" frameborder="0" />').dialog({ 
     modal: true, 
     dialogClass: 'priceBox', 
     title: 'Your title',   
     height: 400, 
     width: 500, 
     draggable: false, 
     resizable: false}); 
});