Reputation: 511
I would like to trigger a dialog after 10 seconds, and this is pretty simple.. Or so I thought :-)
function showPopup() {
$( "#emailPopup" ).dialog({autoOpen:false});
//alert('Dialog shown');
}
$( "#emailPopup" ).dialog("open");
$( "#emailPopup" ).dialog("close");
$(document).ready(function() {
$( "#emailPopup" ).dialog({autoOpen:false});
window.setTimeout(function(){
showPopup();
}, 4000);
jwplayer('videoBox').setup({
flashplayer: '<?php echo asset_url(); ?>swf/player.swf',
file: 'http://www.youtube.com/watch?v=Oj8CwmP_Jm4',
height: 329,
width: 540,
events:{
onBeforePlay:function(){
$('#videoTitle').hide();
$('#videoReplay').hide();
},
onPlay:function(){
videoStarted = true;
clearTimeout(popTO);
},
onComplete:function(){
home.flashGetStarted();
$('#videoReplay').show();
}
},
plugins: 'fbit-1'
});
});
When I run the code showPopup IS run, and I can verify this using debug in Firebug, but after calling the dialog, I still don't see any dialog. If I do a straight call to a dialog outside of the setTimeout, it works... But inside, it's a no go.
Upvotes: 0
Views: 649
Reputation: 151
If I do a straight call to dialog outside of the setTimeout it works... But inside, it's a no go
That's because of a different scope.
Upvotes: 0
Reputation: 171669
In order to use open
method on a dialog you first need to initialize the dialog.
$( "#emailPopup" ).dialog({autoOpen:false});
function showPopup() {
$( "#emailPopup" ).dialog("open");
//alert('Dialog shown');
}
window.setTimeout(function(){
showPopup();
}, 4000);
DEMO: http://jsfiddle.net/QtkBL/
Upvotes: 2