I have read over a dozen posts and answers … to no avail.
What is wrong with this simple code, what am I missing here.
None of tried callbacks works.
$("#project_info").fancybox({
'onComplete': function() {
console.log('log this');
//$.cookie('fcookie', '1', {path: ' / '});
}
});
$("#project_info").fancybox().trigger("click");
and html
<a id="project_info" href="#project_display"></a>
<div style="display: none;">
<div id="project_display" style="width:100px; height:100px; overflow:auto;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
</div>
note: local wamp
edit: also tested on remote server – strip-down file to prevent any interactions – same result
I am answering my own question, to post solution I finally used and tests performed.
Maybe someone finds it useful.
There is something in fancybox 1.3 that kills callbacks, when cookie is used in them.
No time to test, what is it.
Anyone knows? write below.
Just a note: same happened, when I tried to set cookie via .trigger(“click”)
Callbacks work fine with standard click.
What I tried – unsuccessfully.
//trial 1: does not work $("#project_info").fancybox({ onComplete: function() { $.cookie('fcookie', '1', {path: ' / '}); } }); $("#project_info").fancybox().trigger("click"); //trial 2: does not work function StoreCookie() { $.cookie('fcookie', '1', {path: ' / '}); } $("#project_info").fancybox({ onComplete: function() { StoreCookie() } }); $("#project_info").fancybox().trigger("click"); //trial 3: does not work function StoreCookie() { $.cookie('fcookie', '1', {path: ' / '}); } $("#project_info").fancybox({ onComplete: StoreCookie }); $("#project_info").fancybox().trigger("click"); //trial 3: does not work function StoreCookie() { $.cookie('fcookie', '1', {path: ' / '}); } $("#project_info").fancybox({ // }); $("#project_info").fancybox().trigger("click", StoreCookie());//trial 1: does not work $("#project_info").fancybox({ onComplete: function() { $.cookie('fcookie', '1', {path: ' / '}); } }); $("#project_info").fancybox().trigger("click"); //trial 2: does not work function StoreCookie() { $.cookie('fcookie', '1', {path: ' / '}); } $("#project_info").fancybox({ onComplete: function() { StoreCookie() } }); $("#project_info").fancybox().trigger("click"); //trial 3: does not work function StoreCookie() { $.cookie('fcookie', '1', {path: ' / '}); } $("#project_info").fancybox({ onComplete: StoreCookie }); $("#project_info").fancybox().trigger("click"); //trial 3: does not work function StoreCookie() { $.cookie('fcookie', '1', {path: ' / '}); } $("#project_info").fancybox({ // }); $("#project_info").fancybox().trigger("click", StoreCookie());this I settled for
I do not like it very much thou
since cookie is stored somewhat outside of fancybox firing up
if (!$.cookie('fcookie')) { $("#project_info").fancybox({ onComplete: function() { // } }); $("#project_info").fancybox().trigger("click"); } $.cookie('fcookie', '1', {path: ' / '});