定位超大的 jQuery.UI 对话框太远了
我有一个仪表板屏幕,其中充满了排列成三列的对话框。它运作得很好。
var leftContent;
var middleContent;
var rightContent;
var verticalOffset;
$(document).ready(function() {
leftContent = $('#columnTop');
middleContent = $('#columnTop');
rightContent = $('#columnTop');
verticalOffset = (jQuery.browser.safari) ? 40 : 5;
includeJavascriptFile('inlineForumFunctions.js');
$('.dialog').each(function(){
var p = '';
if ($(this).hasClass('dialogLeft')) p = 'posLeft';
if ($(this).hasClass('dialogCenter')) p = 'posCenter';
if ($(this).hasClass('dialogRight')) p = 'posRight';
$(this).dialog({
title: $(this).attr('title'),
maxHeight: 400
}).parent().attr('id', $(this).attr('id') + 'Dialog')
.addClass('cfDialog').addClass(p);
});
$('.cfDialog').css('width', '30%');
$('.cfDialog.posLeft').each(function(){
addToLeftColumn($(this).attr('id'));
});
$('.cfDialog.posCenter').each(function(){
addToCenterColumn($(this).attr('id'));
});
$('.cfDialog.posRight').each(function(){
addToRightColumn($(this).attr('id'));
});
$('.menu ul').hover(function(){
$(this).maxZIndex();
$(this).children().maxZIndex();
});
});
$.maxZIndex = $.fn.maxZIndex = function(opt) {
/// <summary>
/// Returns the max zOrder in the document (no parameter)
/// Sets max zOrder by passing a non-zero number
/// which gets added to the highest zOrder.
/// </summary>
/// <param name="opt" type="object">
/// inc: increment value,
/// group: selector for zIndex elements to find max for
/// </param>
/// <returns type="jQuery" />
var def = {
inc: 10,
group: "*"
};
$.extend(def, opt);
var zmax = 0;
$(def.group).each(function() {
var cur = parseInt($(this).css('z-index'));
zmax = cur > zmax ? cur : zmax;
});
if (!this.jquery)
return zmax;
return this.each(function() {
zmax += def.inc;
$(this).css("z-index", zmax);
});
}
function addToLeftColumn(elementId){
$('#'+elementId)
.position({
my: 'left top',
at: 'left bottom',
of: leftContent,
offset: '0 ' + verticalOffset
});
if ($('#'+elementId).html().length > 0){
leftContent = $('#'+elementId);
}
}
function addToCenterColumn (elementId){
$('#'+elementId)
.position({
my: 'center top',
at: 'center bottom',
of: middleContent,
offset: '0 ' + verticalOffset
});
alert(middleContent.attr('id'));
middleContent = $('#'+elementId);
}
function addToRightColumn (elementId){
$('#'+elementId)
.position({
my: 'right top',
at: 'right bottom',
of: rightContent,
offset: '0 ' + verticalOffset
});
if ($('#'+elementId).html().length > 0){
rightContent = $('#'+elementId);
}
}
...但是,maxHeight
属性似乎被忽略。我有一个高度超过 400 像素的对话框,当屏幕渲染时,对话框的最底部边缘显示在屏幕顶部。
为什么会发生这种情况?
I have a dashboard screen filled with dialogs arranged in three columns. It works pretty well.
var leftContent;
var middleContent;
var rightContent;
var verticalOffset;
$(document).ready(function() {
leftContent = $('#columnTop');
middleContent = $('#columnTop');
rightContent = $('#columnTop');
verticalOffset = (jQuery.browser.safari) ? 40 : 5;
includeJavascriptFile('inlineForumFunctions.js');
$('.dialog').each(function(){
var p = '';
if ($(this).hasClass('dialogLeft')) p = 'posLeft';
if ($(this).hasClass('dialogCenter')) p = 'posCenter';
if ($(this).hasClass('dialogRight')) p = 'posRight';
$(this).dialog({
title: $(this).attr('title'),
maxHeight: 400
}).parent().attr('id', $(this).attr('id') + 'Dialog')
.addClass('cfDialog').addClass(p);
});
$('.cfDialog').css('width', '30%');
$('.cfDialog.posLeft').each(function(){
addToLeftColumn($(this).attr('id'));
});
$('.cfDialog.posCenter').each(function(){
addToCenterColumn($(this).attr('id'));
});
$('.cfDialog.posRight').each(function(){
addToRightColumn($(this).attr('id'));
});
$('.menu ul').hover(function(){
$(this).maxZIndex();
$(this).children().maxZIndex();
});
});
$.maxZIndex = $.fn.maxZIndex = function(opt) {
/// <summary>
/// Returns the max zOrder in the document (no parameter)
/// Sets max zOrder by passing a non-zero number
/// which gets added to the highest zOrder.
/// </summary>
/// <param name="opt" type="object">
/// inc: increment value,
/// group: selector for zIndex elements to find max for
/// </param>
/// <returns type="jQuery" />
var def = {
inc: 10,
group: "*"
};
$.extend(def, opt);
var zmax = 0;
$(def.group).each(function() {
var cur = parseInt($(this).css('z-index'));
zmax = cur > zmax ? cur : zmax;
});
if (!this.jquery)
return zmax;
return this.each(function() {
zmax += def.inc;
$(this).css("z-index", zmax);
});
}
function addToLeftColumn(elementId){
$('#'+elementId)
.position({
my: 'left top',
at: 'left bottom',
of: leftContent,
offset: '0 ' + verticalOffset
});
if ($('#'+elementId).html().length > 0){
leftContent = $('#'+elementId);
}
}
function addToCenterColumn (elementId){
$('#'+elementId)
.position({
my: 'center top',
at: 'center bottom',
of: middleContent,
offset: '0 ' + verticalOffset
});
alert(middleContent.attr('id'));
middleContent = $('#'+elementId);
}
function addToRightColumn (elementId){
$('#'+elementId)
.position({
my: 'right top',
at: 'right bottom',
of: rightContent,
offset: '0 ' + verticalOffset
});
if ($('#'+elementId).html().length > 0){
rightContent = $('#'+elementId);
}
}
...however, the maxHeight
property seems to be ignored. I have one dialog box that is much larger than 400 pixels tall, and when the screen renders, the very bottom edge of the dialog is seen at the top of the screen.
Why is this happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要设置
height
属性,否则为auto
。maxHeight
属性用于可由用户调整大小的对话框。You want to set the
height
property, otherwise it'sauto
. ThemaxHeight
property is used for dialogs that are resizable by the user.