jquery - Target link that opened fancybox within beforeClose function? -
i have fancybox gets opened via:
$('.fancybox').fancybox({ type: 'iframe', fittoview : false, autosize : false, height : 550, width : 650, beforeclose: function () { d = new date(); var imgobj = $('.fancybox').siblings('img'); var imgsrc = imgobj.attr("src"); imgobj.attr("src", imgsrc+"?"+d.gettime()); } });
as can see in beforeclose
function trying target sibling image of link clicked , reload image appending time querystring.
the above code works, works if there 1 fancybox on page. if there more 1 (which i'm wanting do), reloads images on page 1 next link clicked.
is there way can target link clicked open fancybox within beforeclose
function?
i can't find on fancybox documentation how this.
instead of :
var imgobj = $('.fancybox').siblings('img');
... seek :
var imgobj = $(this.element).siblings('img');
see jsfiddle
jquery fancybox fancybox-2
No comments:
Post a Comment