loading fancybox on page load + specific options of fancybox
I know the only way to trigger fancybox on page load is to simulate a click of a hidden link, however the problem is that it seems that this click launches the fancybox with the default options and not taking into consideration the options I've givem... For instance:
$("a.albumPhoto").fancybox({
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'speedIn' : 600,
'speedOut' : 200,
'modal' : true,
'onStart' : 开发者_JAVA百科function(){}
});
$("#albumPhoto_1").fancybox().trigger('click');
I have links with class albumPhoto and the first image is with ID albumPhoto_1, so I trigger it automatically on page load as shown above. However the first image does not take the options mentioned above:
'transitionIn' : 'elastic', 'transitionOut' : 'elastic', 'speedIn' : 600, 'speedOut' : 200, 'modal' : true, 'onStart' : function(){} Does anybody know how I can resolve this?
Thanks in advance!
You could try:
$("#albumPhoto_1").trigger('click');
Because with the code you showed, you're calling the plugin again without options.
Hope this helps. Cheers
精彩评论