2012-05-28 161 views
5

我試圖使用jQuery UI做全屏對話框。jQuery ui全屏對話框

我通過AJAX加載的一些內容,並將結果填入對話框:

function openResource(id) { 
    $.ajax({ 
    url  : "", 
    type  : 'post', 
    dataType : 'html', 
    data : { 
     idRes: id 
    }, 
    success : function(response) { 
     $("#popupRecurso") 
     .html("<div style='float:right; cursor: pointer;' onclick='$(\"#popupRecurso\").dialog(\"destroy\");'>fechar</div>" + response); 

     $("#popupRecurso").dialog({ 
     title  : '', 
     bgiframe : true, 
     position : 'center', 
     draggable : false, 
     resizable : false, 
     dialogClass : 'dialogRecurso', 
     width  : $(window).width(), 
     height  : $(window).height(), 
     stack  : true, 
     zIndex  : 99999, 
     autoOpen : true, 
     modal  : true, 
     open  : function() { 
      $(".ui-dialog-titlebar").hide(); 
     }, 
     error : function(err) { 
      alert(err); 
     } 
     }); 
    } 
    }); 
} 

不幸的是,該對話框不會出現在中心和不正確的尺寸。 有沒有人有過同樣的問題?

感謝

+1

我認爲float屬性可以與位置衝突,在這裏。你能刪除它嗎?如果沒有更完整的示例(html + css,請試試jsFiddle),我無法幫到你。 – BiAiB

+0

@BiAiB,即使沒有任何HTML,問題仍然存在... – jose

+0

'dialogRecurso'類中的任何CSS? – DarthJDG

回答

1

我想看到這個jfiddle得到更好的瞭解可能影響此的任何變量的差異。嘗試刪除對話框屬性的「寬度」和「高度」設置,並將寬度爲100%和高度爲100%的CSS屬性添加到要調用對話框內容的容器中。 「#popupRecurso」。這樣對話屬性不會覆蓋它,並且它隨着任何大小的DOM變化事件而改變。我目前在公司工作很多,並且有類似的問題。我喜歡將CSS屬性設置爲寬度:%120,高度:120%。通過這種方式,即使用戶放大或縮小,您正在查找的對話功能仍然保持真實。希望這會幫助你。快樂的編碼!