Fancybox onComplete function not running

戏子无情 提交于 2020-01-12 20:57:07

问题


For some reason it's just not running the onComplete function. It does however load the fancybox div. My html:

<ul>
    <li class="orange">

           #1 <a href="#text">click here</a>

           <div id="text" class="text">text text text</div>

    </li>
</ul>

My jquery:

 jQuery('li a').fancybox({       
    'autoDimensions':   'false',
    'width' :   631,
    'height':   256,        
    'onComplete':function(){

        alert('running');
        jQuery('.fancybox-skin').css('background-color',colour);
    }
});

the alert doesn't run. I've also tried changing the event function to onClosed and the other events, and nothing.


回答1:


I guess you forgot to specify what version of fancybox you are using.

onComplete is a callback option for fancybox v1.3.x while the fancybox-skin class was introduced until version 2.x, ..... so I assume that you are using version 2.x, aren't you?

Fancybox v2.x options are new and not compatible with previous versions; the equivalent for the onComplete (v1.3.x) option is now the afterLoad (v2.x) callback option.

Check http://fancyapps.com/fancybox/#docs for the complete list of options, methods and callbacks for fancybox v2.x




回答2:


afterShow I think is the proper equivalent to onComplete in Fabxybox 2




回答3:


Fancybox version 2 does not support onComplete. It uses afterLoad.

jQuery('#tips li a').fancybox({       
    'autoDimensions':   'false',
    'width' :   631,
    'height':   256,        
    afterLoad:function(){

        alert('running');
        jQuery('.fancybox-skin').css('background-color',colour); // colour to 'red' for example. typo
    }

});



回答4:


seems like Typo

jQuery('#tips li a').fancybox({       
'autoDimensions':   'false',
'width' :   631,
'height':   256,        
'onComplete':function(){

    alert('running');
    jQuery('.fancybox-skin').css('background-color',colour); // colour to 'red' for example. typo
}
});

Working example




回答5:


Use afterLoad instead of onComplete



来源:https://stackoverflow.com/questions/10816130/fancybox-oncomplete-function-not-running

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!