2012-09-21 142 views
0

我的jQuery对话框有点奇怪的错误。Jquery UI对话框自动打开

当我有它自动打开,对话框是完全空的。如果我退出对话框然后重新打开(通过标准对话框打开事件),则会显示内容。

jQuery的设置:

$("#content_locker").dialog({ 
autoOpen: true, 
modal: true, 
height: 600, 
width: 800 
}); 

Here you can see the webpage that I am working on(它是一个链接缩短服务)。

对话框DIV开始在源148线:

<div id="content_locker" title="Exclusive Content"> 

你会看到对话框是空的。如果你退出并点击解锁按钮,那么正确的html就在那里。

任何想法?

回答

1

模态的内容被隐藏在由于对你的CSS此代码开头:

#content_locker{ 
    visibility: hidden; 
} 

尝试将其更改为:

#content_locker{ 
    diaplay: none; 
} 

它应该做的伎俩;)

+0

谢谢。之前没有注意到这个答案。似乎现在工作正常:) – hellohellosharp

0

当您尝试显示对话框时,看起来HTML尚不可用。你在DOM ready事件指定它..

试试这个

$(function() { 
    $("#content_locker").dialog({ 
     autoOpen: true, 
     modal: true, 
     height: 600, 
     width: 800 
    }); 
    }); 

//如果不行尝试明确 //通过

$("#content_locker").show(); 
+0

尝试了这种不同的变化,但并没有活像k:/感谢你的努力。 – hellohellosharp

1

这取决于顺序显示它。如果您使用autoOpen,则应先填写html内容,然后再启动对话框。 (autoOpen意味着一旦你initilized的对话框,它会打开。)

$("#content_locker").html(the_html_content).dialog({ 
    autoOpen: true, 
    modal: true, 
    height: 600, 
    width: 800 
}); 
+0

好的,我该如何确保html在那里? – hellohellosharp

+0

@ user1019588这取决于你,你应该在对话框打开之前先创建内容。这个来源不是你写的吗? http://clfls.com/js/dwn.php?id=&x=&s=&sid=&limit= – xdazz

+0

是的,这是我写的,但我故意把对话JS从那里放到索引文件中(简单地在页面的底部)在html下面。 – hellohellosharp