Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery对话框在打开时添加许多css类,然后在关闭时不删除它们_Jquery_Jquery Ui_Jquery Ui Dialog - Fatal编程技术网

jQuery对话框在打开时添加许多css类,然后在关闭时不删除它们

jQuery对话框在打开时添加许多css类,然后在关闭时不删除它们,jquery,jquery-ui,jquery-ui-dialog,Jquery,Jquery Ui,Jquery Ui Dialog,我的jQuery对话框工作得非常好,除了每次打开对话框时都会附加以下内容 js flexbox flexboxlegacy canvastext webgl不接触地理位置postmessage websqldatabase indexeddb hashchange history dragandrop websockets rgba hsla multipleebgs背景尺寸边框图像边框半径box shadow text shadow不透明度cssanimations csscolumns cs

我的jQuery对话框工作得非常好,除了每次打开对话框时都会附加以下内容

js flexbox flexboxlegacy canvastext webgl不接触地理位置postmessage websqldatabase indexeddb hashchange history dragandrop websockets rgba hsla multipleebgs背景尺寸边框图像边框半径box shadow text shadow不透明度cssanimations csscolumns cssgradients cssreflections cstransforms cstransforms3d cstranitionsfontface生成内容视频音频本地存储会话存储webworkers应用程序缓存svg内联svg smil SVGCLIPPATHES

当您关闭时,它们不会被移除。但是,当您再次打开对话框时,它将重新添加这些类。因此,最终html元素的class属性很快变成半页

对话框设置

$(dialogSelector).dialog({
    modal: true,
    title: "Current Schedule",
    width: 450,
    height: 500
});
全功能:

function ViewScheduleDialog(dialogSelector, href, id) {
    $.ajax({
        url: href,
        type: "GET",
        data: { SelectedID: id },
        success: function (data, textStatus, jqXHR) {
            $(dialogSelector).html(data);
            $(dialogSelector).dialog({
                modal: true,
                title: "Current Schedule",
                width: 450,
                height: 500
            });
        }
    });
}
问题:

它添加这些css类而不删除它们有什么原因吗

我也尝试过:

function ViewScheduleDialog(dialogSelector, href, id) {
    $.ajax({
        url: href,
        type: "GET",
        data: { SelectedID: id },
        success: function (data, textStatus, jqXHR) {
            $(dialogSelector).html(data);
            $(dialogSelector).dialog({
                modal: true,
                title: "Current Schedule",
                width: 450,
                height: 500
            });
        }
    });
}
使对话框在doc ready上执行上述对话框设置,然后仅在单击“我的链接”时打开/关闭。html元素仍然大量使用css类填充

技术:

function ViewScheduleDialog(dialogSelector, href, id) {
    $.ajax({
        url: href,
        type: "GET",
        data: { SelectedID: id },
        success: function (data, textStatus, jqXHR) {
            $(dialogSelector).html(data);
            $(dialogSelector).dialog({
                modal: true,
                title: "Current Schedule",
                width: 450,
                height: 500
            });
        }
    });
}
  • ASP.NETMVC5
  • jQueryV1.10.2和jQueryUI1.10.4
  • 引导v3.0.0(在引导后加载jQuery UI)

确保仔细检查代码中是否包含所有正确的
.css
文件

您是否尝试使用
jquery
删除该类?大概是这样的:

$('#dialogSelector').removeClass('open');

隐藏和显示对话框的代码在哪里?实际上就是这样,我想我会添加更多,但我只是使用对话框右上角的X并使用我显示的代码段打开;它不仅仅是打开它。在它被创建之后,它们是一个打开的函数:我将它切换为在document.ready上用autoOpen创建对话框,然后使用.dialog(“打开”),但同样的情况也发生了。它仍然会附加这些类。这确实解决了这个问题,但是,它并没有完全回答我的问题,因为我在问为什么每次打开对话框时都会附加这些类。我猜每次打开对话框时,您都会调用
$(dialogSelector).html(数据)
不断追加数据,这会对
元素产生什么影响?确切地说,它在页面
div#schedule
上选择一个div,并将返回的html放入其中。因此,除非我被诅咒,否则它不应该触及
元素。