In my JQuery Mobile site I've added a tool-tip dialog box to open when the page is load and It'll disappear after 5sec. My code is similar to follows,
<div data-role="popup" id="popupInfo">
<p>This is a completely basic popup, no options set.<p>
</div>
<script type="text/javascript">
$(document).live( 'pagechange',function(event){
$('#popupInfo').popup("open")
setTimeout(function() {
$('#popupInfo').popup("close");
}, 5000);
});
</script>
This update is working fine in all devices except in IPhone 5 iOS 6. Because when I tried to load my JQuery mobile page with above script in IPhone 5 iOS 6 device it redirect me to the previous page when the popup closing. I'm not sure what I've missed here but for me it looks like jQuery Mobile popup("close") function is not supporting for IPhone 5 iOS 6.
Also when the tool-tip load following hash tag text appending to the URL how can we avoid this #&ui-state=dialog
Could anyone please let me know how can we solve this issue ?
I've even tried following code also;
$(document).on('pagechange',function(event){
$('#popupInfo').popup("open").delay(2000).popup("close");
});
But this is not working at all
Got it. Add data-history="false"
to the popupBasic
Popup div.
<!-- Button / works without it -->
<a href="#popupBasic" data-rel="popup">Open Popup</a>
<!-- Popup #popupBasic -->
<div data-role="popup" id="popupBasic" data-history="false">
<p>This is a completely basic popup.<p>
</div>
JS:
<script type="text/javascript">
$(document).live( 'pagechange',function(){
$('#popupBasic').popup("open")
setTimeout(function() {
$('#popupBasic').popup("close");
}, 5000);
});
</script>
JSfiddle: Popup
Also alternatively..jquery mobile surrounds pop-ups with a div having ID = "yourpopupid-popup" So you can simply hide that div.
for example: < div id="basic" data-role="popup" > I am pop up< / div > , then you can close it by : $('#basic-popup').hide();
Use two functions hide() or you can use close() function on clicking the button
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With