2013-03-04 64 views
0

抱歉没有提供小提琴,我不能让它在那里设置。jQuery的移动弹出不关闭

但是,我使用以下代码以编程方式打开和关闭弹出窗口。只是它不关闭并保持打开状态。我究竟做错了什么?

<!DOCTYPE html> 
<html> 
<head> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> 
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.js"></script> 

    <script> 
    $(document).ready(function() 
    { 
     $("#initialpopup").popup("open"); 

     setTimeout(function() 
     { 
      $("#initialpopup").popup("close"); 
     }, 500);  

    }); 
    </script> 
</head> 
<body> 

    <div data-role="page" data-theme="a" data-content-theme="c"> 

     <div data-role="popup" id="initialpopup" data-overlay-theme="a" data-theme="a">Foobar</div> 


    </div> 

</body> 
</html> 
+0

你要在5秒后自动关闭呢? – CR41G14 2013-03-04 16:52:13

+0

可能的重复:http://stackoverflow.com/questions/13154278/in-jquery-mobile-why-doesnt-this-popup-close – WildCrustacean 2013-03-04 16:55:16

+0

500毫秒后。超时标志着ajax调用的完整回调处理程序。 – 2013-03-04 16:59:54

回答

1

你可以尝试

$('#initialpopup').popup('open', {transition: 'pop'}); 
window.setTimeout('$("#initialpopup").popup("close");', 500); 
+0

这为什么会有所作为?使用eval'd字符串而不是lambda函数有意义吗? – thekingoftruth 2013-09-17 19:25:53