简体   繁体   English

jQuery对话框不会弹出

[英]jQuery dialog box does not pop up

I have a dialog box that is supposed to pop up if the user is not logged in, and presses the "vote up" link on this page: http://www.problemio.com 我有一个对话框,如果用户未登录,应该会弹出该对话框,然后按此页面上的“投票”链接: http : //www.problemio.com

I have some JavaScript here: problemio.com/js/problemio.js and I declare that popup in the global variables like this: 我在这里有一些JavaScript: problemio.com/js/problemio.js ,我在全局变量中声明了该弹出窗口,如下所示:

var $dialog = $('#loginpopup')
    .dialog({
        autoOpen: false,
        title: 'Login Dialog'
    }); 

var $problemId = $('#theProblemId', '#loginpopup');

$("#newprofile").click(function () 
{
    $("#login_div").hide();
    $("#newprofileform").show();
});

but not exactly sure if the #newprofile code is right, or how to make it global, or whether it can't be global. 但不能完全确定#newprofile代码是否正确,如何使它成为全局代码,或者是否不能是全局代码。 This confusion stems from me being kind of new at this. 造成这种混乱的原因是我对此感到陌生。

The JavaScript console in Chrome does not show any errors relevant to this, which is even more confusing. Chrome中的JavaScript控制台不会显示与此相关的任何错误,这更加令人困惑。

Any ideas on what I might be doing wrong? 关于我可能做错了什么的任何想法?

Thanks!! 谢谢!!

Try using 尝试使用

$("#loginpopup").dialog(); $( “#loginpopup”)对话框()。

A call to 致电

 $(foo).dialog() 

will initialize a dialog instance and will auto-open the dialog by default. 将初始化对话框实例,默认情况下将自动打开对话框。 If you want to reuse a dialog, the easiest way is to disable the "auto-open" option with: 如果要重用对话框,最简单的方法是通过以下方式禁用“自动打开”选项:

 $(foo).dialog({ autoOpen: false }) 

and open it with 并用

 $(foo).dialog('open') 

. To close it, use 要关闭它,请使用

 $(foo).dialog('close') 

jQuery UI Dialog jQuery UI对话框

I'm a bit confused, not sure if your question is complete. 我有点困惑,不确定您的问题是否完整。 However, you have autoOpen: false set on the dialog, so you have to manually open it with: 但是,您在对话框上设置了autoOpen: false ,因此必须使用以下命令手动将其打开:

$("#loginpopup").dialog("open");

in your "vote up" click handler. 在您的“投票”点击处理程序中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM