从另一个弹出窗口打开弹出窗口 [英] Opening a popup window from another popup

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

问题描述

我的网站内置HTML5,CSS3和Jquery-moblie ..

My site is built in HTML5, CSS3 and Jquery-moblie..

我使用Jquery-mobile的弹出式视窗。

I use pop-ups of Jquery-mobile.

在一个弹出窗口我有一个按钮,当按下我想要当前弹出窗口将关闭,另一个将打开。

On a popup window I have a button that when pressed I want the current pop-up window will close and another will open.

以这种方式:

弹出窗口:

    <div id="MyFirstPopup" data-role="popup" data-theme="a" data-overlay-theme="a" class="ui-content">
        <a  data-role="button" data-transition="none" data-theme="b"
            onclick="ShowSecond();" data-icon="forward" data-iconpos="left" >
        </a>
    </div>

    <div id="MySecondPopup" data-role="popup" data-theme="a" data-overlay-theme="a" class="ui-content">
     ...
    </div>

JS:

function ShowSecond()
{
   $('#MyFirstPopup').popup('close');
   $('#MySecondPopup').popup('open');
}

无效。

有人有解决方案吗?

推荐答案

首先不要使用 onclick =ShowSecond

First don't use onclick="ShowSecond();" directly on an a tag.

我已经创建了一个工作示例: http://jsfiddle.net/Gajotres/8Arrt/

I have created you a working example: http://jsfiddle.net/Gajotres/8Arrt/

添加点击事件this:

Add click event like this:

 $('#popup-button').live('click', function(e) {
     setTimeout(function(){$('#MySecondPopup').popup('open');},500)
     $('#MyFirstPopup').popup('close');
});

或使用.on(如果您使用新的jQuery库,一个是关闭,但你也不能打开现在弹出的事件关闭最后一个,所以setTimeout函数是需要的。设置你需要/想要的任何超时。

Or use .on( if you are using new jQuery library. You can not open new popup unless old one is close but you also can't open now popup in event that closes last one, so setTimeout function is needed. Set whatever timeout you need/want.

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

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