jQueryUI对话框正在破坏我的页面

jQueryUI对话框正在破坏我的页面,jquery,jquery-ui,Jquery,Jquery Ui,我正在尝试将一个页面加载到jQueryUI的.dialog()功能中,该功能运行良好。但在关闭对话框后,我的页面的其余部分仍处于禁用状态 $(function() { var w = $(document).width(); var h = $(document).height(); $( "#diag" ).dialog({ //dialog box settings autoOpen: false, //do not open au

我正在尝试将一个页面加载到jQueryUI的
.dialog()
功能中,该功能运行良好。但在关闭对话框后,我的页面的其余部分仍处于禁用状态

$(function() {
    var w = $(document).width();
    var h = $(document).height();

    $( "#diag" ).dialog({   //dialog box settings
        autoOpen: false,        //do not open automatically
        show: { 
            effect: "slide"     //slide frame in
        },
        modal: true,            //disable the other elements
        width: w,               //set width to window width
        height: h               //set width to window height
    });

    $( ".icon" ).click(function() { //on .icon click
        var v = $(this).attr('value'); //load value of clicked item into v
        $( "#diag" ).load(v).dialog( "open" ); //open the #diag box
    });
});

当我去掉
.load(v)
并注释掉v的初始化时,
.dialog()
工作得非常好。我被难住了。

问题可能是
.load
异步替换内容,因此您可能会丢失所有正确解除对话框的事件绑定

请尝试以下方法:

var v = $(this).attr('value');
var dialogContent = $('#diag');
dialogContent.load(v, function() {
    dialogContent.dialog('open');
});

换句话说,在打开对话框之前等待加载完成。

问题可能是
.load
异步替换内容,因此您可能会丢失所有正确解除对话框的事件绑定

请尝试以下方法:

var v = $(this).attr('value');
var dialogContent = $('#diag');
dialogContent.load(v, function() {
    dialogContent.dialog('open');
});

换句话说,在打开对话框之前,等待加载完成。

将所有内容移动到单击功能中,使所有内容正常工作。谢谢大家的帮助

$(function() {
$( ".icon" ).click(function() {  //on .icon click
    var w = $(document).width();
    var h = $(document).height();

    $( "#diag" ).dialog({   //dialog box settings
       show: {  
       effect: "slide"      //slide frame in
       },
       modal: true,         //disable the other elements
       width: w,            //set width to window width
       height: h                //set width to window height
});
    var v = $(this).attr('value');  //load value of clicked item into v
$( "#diag" ).load(v).dialog( "open" );      //open the #diag box
});

});

将所有内容移动到click函数中,使所有内容正常工作。谢谢大家的帮助

$(function() {
$( ".icon" ).click(function() {  //on .icon click
    var w = $(document).width();
    var h = $(document).height();

    $( "#diag" ).dialog({   //dialog box settings
       show: {  
       effect: "slide"      //slide frame in
       },
       modal: true,         //disable the other elements
       width: w,            //set width to window width
       height: h                //set width to window height
});
    var v = $(this).attr('value');  //load value of clicked item into v
$( "#diag" ).load(v).dialog( "open" );      //open the #diag box
});

});

您正在加载的页面是否包含jQuery和jQuery UI的另一个副本?它没有。我包括了它,重新测试,它让我更接近!现在回到主页面时,将鼠标悬停在工作上方。如果不刷新,我仍然无法重新打开窗口。您正在加载的页面是否包含jQuery和jQuery UI的另一个副本?它没有。我包括了它,重新测试,它让我更接近!现在回到主页面时,将鼠标悬停在工作上方。我仍然无法在不刷新的情况下重新打开窗户。凯文的直觉看起来也很可能。这是不可能的:(因此,我正在拉的按钮值保留了文件名。它正在正确加载对话框。关闭对话框后,我必须刷新页面,以便重新打开我刚刚关闭的对话框。您如何关闭对话框?可能问题在于该代码。我使用的是“X”在对话框的右上角。它似乎是默认值。别担心,这是表中的假数据。在关闭对话框时是否有JS错误阻止对话框完成关闭过程?Kevin的直觉看起来也很可能。这是一个不可能的结果:(因此,我正在拉的按钮值保留了文件名。它正在正确加载对话框。关闭对话框后,我必须刷新页面,以便重新打开我刚刚关闭的对话框。您如何关闭对话框?可能问题在于该代码。我使用的是“X”在对话框的右上角。它似乎是默认值。别担心,这是表中的假数据。在关闭对话框时,是否有JS错误阻止对话框完成关闭过程?