jQuery Mobile 1.3.1 Uncaught Error:无法在初始化之前在弹出窗口上调用方法;尝试将方法称为“打开" [英] jQuery Mobile 1.3.1 Uncaught Error: cannot call methods on popup prior to initialization; attempted to call method 'open'

查看:133
本文介绍了jQuery Mobile 1.3.1 Uncaught Error:无法在初始化之前在弹出窗口上调用方法;尝试将方法称为“打开"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的登录对话框,该对话框在加载文档时弹出:

I have a simple login dialog which I pop-in on document load:

<div data-role="popup" id="signupPopup" data-theme="a" class="ui-corner-all" data-dismissible="false" data-add-back-btn="true" data-transition="pop">
    <h3 class="centerText">Login</h3>

    <div class="popup">
        <form>              
            <input type="email" name="email" id="email" class="centerText" placeholder="email" data-theme="a"/>
            <input type="text"  name="zip"   id="zip"   class="centerText" placeholder="pass" data-theme="a"/>                  
        </form>
    </div>
</div>

$(document).ready(function(){
    $("#signupPopup").popup('open');
});

这是示例的 jsFiddle .现在,在正常负载下,弹出窗口会正常弹出,然后将URL哈希更新为 http://myurl.com/#&ui-state=dialog ,如果我在URL中单击此哈希值重新加载,则会收到js错误:Uncaught Error: cannot call methods on popup prior to initialization; attempted to call method 'open'.

This is a jsFiddle of the example. Now, on a normal load the popup pops-up without a problem, and then it updates the url hash to http://myurl.com/#&ui-state=dialog and if I click reload with this hash in the url I get the js error: Uncaught Error: cannot call methods on popup prior to initialization; attempted to call method 'open'.

我试图在 http://view.jquerymobile.com上复制相同的行为/master/demos/widgets/popup/

通过将has添加到这样的链接中:

by adding the has to the link like this:

http://view.jquerymobile.com /master/demos/widgets/popup/#& ui-state = dialog ,但是我无法复制相同的错误.因此,想知道是否有人遇到此错误以及他/她如何解决该错误?顺便说一句,我确实检查了此错误的所有来自google的前20个链接,但它们都没有帮助,包括SO的一些链接.另外,值得注意的是,如果我使用jQuery Mobile 1.2和jQuery 1.7.1,则不会出现此错误.

http://view.jquerymobile.com/master/demos/widgets/popup/#&ui-state=dialog but there I can't replicate the same error. So, am wondering if someone encountered this error and how he/she solved it? Btw, I did check all of the top 20 links from google on this error, but none of them helped, including few from SO. Also, worth noting is that I don't get this error if I use jQuery Mobile 1.2 and jQuery 1.7.1 .

我正在使用jQuery Mobile 1.3.1和jQuery 1.9.1.

I'm using jQuery Mobile 1.3.1 and jQuery 1.9.1.

推荐答案

您可能没有页面"元素内的弹出HTML.

You may not have the popup HTML inside a "page" elemenet.

<div data-role="page"> <!-- popup inside here --> </div>

我发现,当我不小心将其放置在页面之外时,我需要先调用.popup()进行初始化,但是弹出窗口中的按钮或其他元素从未使用这种方法进行初始化.根本解决方法是将弹出窗口放在page元素内.

I found that when I accidentally put it outside the page that I needed to call .popup() to initialize first, however buttons or other elements inside the popup are never initialized with this approach. The root fix is to put the popup inside the page element.

这篇关于jQuery Mobile 1.3.1 Uncaught Error:无法在初始化之前在弹出窗口上调用方法;尝试将方法称为“打开"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆