我打开jQuery UI对话框并在其中加载一些内容。但是,当我调整浏览器jq对话框不改变它的宽度/高度。我尝试了一些东西,但没有运气。在这里我怎么打开它:在对话框已经打开如何使用浏览器调整jQuery UI对话框的大小
$(document).ready(function() {
var wWidth = $(window).width();
var dWidth = wWidth * 0.9;
var wHeight = $(window).height();
var dHeight = wHeight * 0.9;
$(".openDialog").live("click", function (e) {
e.preventDefault();
$("<div></div>")
.addClass("dialog")
.attr("id", $(this).attr("data-dialog-id"))
.appendTo("body")
.dialog({
title: $(this).attr("data-dialog-title"),
close: function() { $(this).remove() },
modal: true,
resizable: false,
show: 'fade',
width: dWidth,
height: dHeight,
create: function (event, ui) {
$(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").css("display", "none");
$(this).parents(".ui-dialog").css("padding", 0);
$(this).parents(".ui-dialog").css("border", 0);
$(this).parents(".ui-dialog:first").find(".ui-dialog-content").css("padding", 0);
$(this).parents(".ui-dialog:first").find(".ui-dialog-content").css("background", "#000000");
$(this).parents(".ui-dialog:first").find(".ui-dialog-content").css("overflow", "hidden");
}
})
.load(this.href);
});
$(window).resize(function() {
var wWidth = $(window).width();
var dWidth = wWidth * 0.9;
var wHeight = $(window).height();
var dHeight = wHeight * 0.9;
$(".openDialog").dialog("option", "width", dWidth);
$(".openDialog").dialog("option", "height", dHeight);
});
});
我把我的整个功能为您提供了调整大小功能加载UI对话框。我得到对话框调整大小的浏览器调整大小,但然后我ui对话框不是模态它显示为一个页面,我得到错误:未捕获ReferenceError:$未定义 (匿名函数) – 1110 2012-03-26 21:34:14
我会离开它们作为两个单独的功能。这样调整大小不会影响对话框的init。只需将文件就绪功能中的代码放在窗口大小调整功能后面即可。 – 2012-03-27 15:00:57
我已更新问题。我必须做一些错误的事情,因为它没有调整大小:( – 1110 2012-03-27 16:00:15