jQuery:设置模式对话框的覆盖颜色 [英] jQuery: Set modal dialog overlay color

查看:107
本文介绍了jQuery:设置模式对话框的覆盖颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用jquery ui弹出一个模态对话框,其中的覆盖物是完全黑色的.我知道我可以在主题中设置它,但是我不希望所有对话框都带有黑色覆盖.只是其中之一.

I would like to pop a modal dialog using jquery ui where the overlay is completely black. I know that I can set this in the theme, but I do not want all dialogs to have a black overlay. Just one of them.

是否可以按对话框配置对话框的背景(覆盖)颜色?也许什么时候创建的?

Is there a way to configure a dialog's background (overlay) color on a per-dialog basis? Perhaps when it is created?

TIA

推荐答案

弗雷德里克的回答很接近,但给我留下了一个问题:我在该页面上有多个对话框,并且在更改了一个对话框的覆盖后,它会更改所有页面,直到重新加载页面为止.但是,它确实给了我一个主意;

Frederic's answer was very close but it left me with one problem: I had more than one dialog on that page, and after I changed the overlay for the one dialog, it changed all of them until the page was reloaded. However, it did give me an idea;

首先,我将默认值存储到变量(页面范围)中,然后设置我的自定义样式.

First I stored the default values into variables (page scope), and then set my custom style.

var overlay = $(".ui-widget-overlay");
baseBackground = overlay.css("background");
baseOpacity = overlay.css("opacity");
overlay.css("background", "#000").css("opacity", "1");

然后,当对话框关闭时,我恢复了这些值.

Then when the dialog is closed, I restored those values.

$(".ui-widget-overlay").css("background", baseBackground).css("opacity", baseOpacity);

将它们存储在变量中的主要原因(与将它们重置为显式值相反)是出于可维护性.这样,即使site.css发生更改,它也可以正常工作.

The main reason for storing them in variables (as opposed to resetting them to explicit values) is for maintainability. This way, even if the site.css changes, it will work.

感谢您的帮助!

这篇关于jQuery:设置模式对话框的覆盖颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆