关闭上一个弹出窗口后,jQuery Mobile弹出窗口无法打开 [英] jQuery Mobile popup does not open after closing previous popup

查看:78
本文介绍了关闭上一个弹出窗口后,jQuery Mobile弹出窗口无法打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jQuery弹出窗口,它接收可能导致错误的用户输入。如果有错误,我希望有第二个弹出窗口,但我无法正常工作。

I have a jQuery popup that takes in user input which can lead to errors. I want to have a 2nd popup come up if there are errors, but I cannot get this working.

这是一个简单的例子,我在jsfiddle也有: http://jsfiddle.net/tz4ju/2/

Here is a boiled down example, which I also have in jsfiddle: http://jsfiddle.net/tz4ju/2/

HTML:

<div data-role="page" id="home">
    <div data-role="popup" id="errorDialog" class='ui-corner-none ui-content'>
        <p id="errormsg"></p>
    </div>

    <div data-role="popup" id="addFolderDialog" class='ui-corner-none portalpopup'>
        <div data-role='content'>
            <p></p>
            <div data-role="fieldcontain">
                <label for="name">New Folder:</label>
                <input type="text" name="name" id="newfolder_val" value="" class="ret_submit" rel="adddir_submit" />
            </div>
            <div class="clearfix">
                <a data-role="button" data-inline="true" data-theme="b" id="adddir_submit" onclick='create_folder_submit()'>Add Folder</a>
                <a data-role="button" data-inline="true" data-rel='back'>Cancel</a>
            </div>
        </div>
    </div>

    <p><a href="#addFolderDialog" data-rel="popup">Open Popup</a></p>
</div>

JavaScript:

The JavaScript:

window.create_folder_submit = function () {
    $("#addFolderDialog").popup("close");
    $("#errormsg").text("ERROR!");
    $("#errorDialog").popup("open");
}

顺便说一句,如果我打电话给 $( #errorDialog)。弹出(打开)在其他任何地方,它都有效。我做错了什么?

By the way, if I call $("#errorDialog").popup("open") anywhere else, it works. What am I doing wrong?

推荐答案

根据这个文档(请参阅页面末尾) jquery mobile中不允许链接弹出窗口。

According to this Documentation (see at the page end) Chaining popups are not allowed in jquery mobile.

你可以像下面那样获得链接弹出窗口。

You can achive the chaining popup like the following.

$( document ).on( "pageinit", function() {
$( '.popupParent' ).on({
    popupafterclose: function() {
        setTimeout( function(){ $( '.popupChild' ).popup( 'open' ) }, 100 );
    }
});
});

请参阅 小提琴演示

这篇关于关闭上一个弹出窗口后,jQuery Mobile弹出窗口无法打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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