从另一个弹出窗口打开弹出窗口
我的网站内置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.