I have problem with fancybox.
I want to write a function that will run when the fancybox opened. How and when to call the function?
Example:
function myFunc() {
alert("Opened!");
}
$('.content a').fancybox({
'hideOnContentClick': false ,
'callBackOnShow': myFunc(), // This not working! It call function when page is loaded
'frameWidth': 920,
'frameHeight': 530
});
Fancybox saves you time and helps to easily create beautiful, modern overlay windows containing images, iframes, videos or any kind of HTML content.
Here is the code: if ($('div#fancybox-frame:empty'). length >0) { alert('it is empty'); $.
Instead of myFunc()
use myFunc
. In javascript, a function with parens (and/or args) means you want to call it. A function name without them means you just want a reference to that function (which is probably what fancybox wants from you)
This works
$("#element").fancybox({
onStart : function() {
return window.confirm('Continue?');
},
onCancel : function() {
alert('Canceled!');
},
onComplete : function() {
alert('Completed!');
},
onCleanup : function() {
return window.confirm('Close?');
},
onClosed : function() {
alert('Closed!');
}
});
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