Html 未捕获的错误:无法在初始化之前调用弹出窗口中的方法;
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13419358/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught Error: cannot call methods on popup prior to initialization;
提问by Cullen Sanderson
I'm developing a page and I import another page with popups on it using @Html.Partial("AddCommentPopup")
and on pages where I am using an <a href="#pupupIDhere" data-rel="popup etc..>
It works perfectly fine. On this page I need to do it differently though because of the way JQM works with links. So I'm using
<div onclick="console.log('divclicked');$('#statusUpdate').popup('open');">
. And the console tells me that it is being clicked, but it doesn't open the popup and throws this error:
Uncaught Error: cannot call methods on popup prior to initialization; attempted to call method 'open'.
我正在开发一个页面,我使用@Html.Partial("AddCommentPopup")
和在我使用的页面上导入了另一个带有弹出窗口的页面<a href="#pupupIDhere" data-rel="popup etc..>
。它工作得非常好。在此页面上,由于 JQM 处理链接的方式,我需要以不同的方式执行此操作。所以我正在使用
<div onclick="console.log('divclicked');$('#statusUpdate').popup('open');">
. 控制台告诉我它正在被点击,但它没有打开弹出窗口并抛出这个错误:未捕获的错误:在初始化之前无法调用弹出窗口的方法;试图调用方法“open”。
Any idea how to fix this?
知道如何解决这个问题吗?
回答by Gabe
Try initializing the div as a popup first, then open it...
首先尝试将 div 初始化为弹出窗口,然后将其打开...
<div onclick="console.log('divclicked');
$('#statusUpdate').popup();
$('#statusUpdate').popup('open');">
</div>
回答by Ashisha Nautiyal
回答by stylestep
yeah,it's useful , $('#statusUpdate').popup();
是的,它很有用,$('#statusUpdate').popup();
$('#statusUpdate').popup('open');
$('#statusUpdate').popup('open');
$('#statusUpdate').popup(); /* this this for initialization*/
$('#statusUpdate').popup(); /* 这是用于初始化的 */
$('#statusUpdate').popup('open'); /this for operation/
$('#statusUpdate').popup('open'); /这个用于操作/