So my jqueryMobile dialog is closes as soon as it is opened on page load in Safari only. I have a click event attached to a link that opens it. Works just fine on all other browsers, just not Safari. Also not I have a cookie set so it only opens once. Here is a link to check it out. jqueryMobile dialog issue Any help will be greatly appreciated.
<a id='dialog' href="dialog.html" data-rel="dialog" >Dialog</a>
<script>
function openDialog() {
setTimeout(function () {
$.mobile.changePage('dialog.html');
}, 100); // delay above zero
}
$(function() {
if ($.cookie('dialog_shown') == null) {
$.cookie('dialog_shown', 'yes', { expires: 7, path: '/' });
openDialog();
}
});
First, I have downloaded your page source and tested this on Safari and Chrome. This is purely a web-kit browsers problem.
Don't take this as a critique but there are some many problems in your code that I don't know where to start.
First problem
First jQuery Mobile is strict with its design, all your pages must be wrapped inside a:
Choose any page id you want. If you want jQuery Mobile to behave this MUST be done.
Second problem
jQuery Mobile don't like document ready, while a lot of things will work with it they will not work properly. jQuery Mobile developers have create page events to remedy this. If you want to find more read my other article: jQuery Mobile: document ready vs page events. I am mentioning this because openDialog function must be executed during the pageshow event (everything will be clear when you see final code).
Third problem
jQuery Mobile dialogs don't work well if separated in an another HTML file. That is why I have placed it inside a original HTML file. Without this problem we don't need to fix prolem 1. and problem 2. Because we now have a dialog at the same page as rest of the HTML, original content MUST be wrapped inside a jQM page and we need pageshow event to trigger this new dialog.
Fourth problem
This is just a good practice but always kill interval or timer unless you want it to do everything over and over again.
Final code
I have removed only cookie handling because it prevented me from testing this out. You can download this code and test it locally.