本文介绍了在向jQuery UI对话框添加类时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用dialogClass属性向我的jQuery对话框添加一个附加类.这是javascript:

I'm trying to add an additional class to my jQuery dialog with the dialogClass property. Here's the javascript:

$(function(){
    $( "#toogleMAmaximized" ).dialog({
            title: 'Missions and Achivments',
            autoOpen: false,
            height: 500,
            width: 700,
            modal: true,
            dialogClass: 'noPadding',
            buttons: {
                    Cancel: function() {
                            $( this ).dialog( "close" );
                    }
            },
            close: function() {
                    allFields.val( "" ).removeClass( "ui-state-error" );
            }

    })
    $( "#toogleMAminimized" ).click(function() {
            $( "#toogleMAmaximized" ).dialog( "open" );
            $( "#toogleMAmaximized" ).dialog({dialogClass:'noPadding'});
    });
})

<div id="toogleMAminimized" style="" class="noPadding">
<div class="" style="cursor: pointer;position: absolute;right: 0;top: 45px;"><img src ="images/MAminimized.png" alt="missions and achivments"/></div>
</div>

只要您需要,我的html代码

Just in case you need it, my html code

<div id="toogleMAmaximized" >
<div id="missions">
    <div id="mission1" missiontitle="A new home!" missionpoint="1" missionicon="images/missions/icon/anewhome-icon.png" missionimage="images/missions/anewhome.png" made="f" class="mission notDone">  </div>
</div>
<div id="achivments">
    <div id="achivment1" achivmenttitle="Lucha sin cuartel!" achivmentpoint="10" achivmenticon="images/achivments/icon/1.png" achivmentimage="images/achivments/icon/luchasincuartel-plata-ico.png" made="t" class="achivment done">  </div>
</div>
</div>

如您所见,我尝试了多种方式添加类,尝试了所有可能的组合,但仍得到相同的结果:没有noPadding

As you can see, I've tried to add the class in many ways, I've tried all possible combinations but keep getting the same result: no noPadding class

推荐答案

您的noPadding类已成功添加到对话框中.我通过将标记和脚本放在小提琴中并加载jQuery UI 1.8.16(测试时使用的版本)来确认这一点.可以在 http://jsfiddle.net/QHJKm/3/上在线获得该测试.

Your noPadding class is being added successfully to the dialog. I have confirmed this by placing your markup and scripts within a fiddle, and loading jQuery UI 1.8.16 (the version you were testing with). This test is available online at http://jsfiddle.net/QHJKm/3/.

我怀疑这里的困惑与预期的效果noPadding将会对对话框本身产生影响.可能是您将其缺乏效果解释为一开始并未添加效果的指示.正如您在示例中所指出的那样,我的风格非常大胆,红色背景.这很快确认该类确实已添加到对话框中.

I suspect the confusion here is with the expected effect noPadding is going to have on the dialog itself. It could be that you interpreted its lack of effect as an indication it wasn't added to begin with. As you'll note in my example, I've got with a rather bold style, a red background. This quickly confirms that the class is indeed being added to the dialog.

这篇关于在向jQuery UI对话框添加类时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-02 01:57