个性化类中的JQuery UI对话框

时间:2013-08-15 19:39:00

标签: jquery jquery-ui

我有一个应用了 class =“dialog-error”的div。在jQuery中,我为这个div指定了一个对话框: $('。dialog-error')。dialog({});

我希望能够仅定位和修改属于我的“对话框错误”类的ui类,所以我尝试了:

.dialog-error .ui-dialog-titlebar {
    background-color: red;
    background-image: none;
    color: white;
    font-size:small;
}
.dialog-error .ui-dialog-buttonpane { 
    font-size: 0.8em; 
} 

但没有适用。如何仅定位属于我的类的UI类?

我想要实现的是至少有两个不同的类别(例如:错误对话和成功对话),并通过更改div的类来回切换。 非常感谢。

jquery代码:

$('.dialog-error').dialog({
                resizable: false,
                height: 200,
                width: 350,
                modal: true,
                dialogClass: "dialog-error", //use this to affect the css 
                title: "Missing Information!",
                buttons: {
                    "Back": function() {
                        $(this).dialog("close");
                    }
                }

            });

HTML code:

<div class = "dialog-error" style = "display:none;"></div>

根据建议添加'dialogClass:“dialog-error”'行,但现在ui对话框根本不显示。

1 个答案:

答案 0 :(得分:2)

如果我记得jQuery UI首先从DOM中删除你的div,那么它会创建一个新的并将原始文件放在内容区域中。你的CSS类没有应用,因为你的div在里面对话框,而不是包装它

要完成您的要求,请在初始化模态时尝试设置 dialogClass 选项。

请参阅:http://api.jqueryui.com/dialog/#option-dialogClass

相关问题