onComplete not working

696 views
Skip to first unread message

Tom

unread,
Jan 6, 2011, 5:08:49 PM1/6/11
to fancybox
I can't seem to get onComplete to work properly. For some reason, it's
firing at the beginning of the slideshow. Here's my code:


$("a#button-look").fancybox({
'onComplete' : function() { alert("here") },
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'speedIn' : 600,
'speedOut' : 200
});


Any ideas? Thanks!

Tom

JFK

unread,
Jan 7, 2011, 1:10:29 AM1/7/11
to fancybox
well, that is normal
onComplete will be called just right after the content is loaded
see callback examples here
http://fancybox.net/home

what behavior you were expecting then?

Tom

unread,
Jan 7, 2011, 12:16:24 PM1/7/11
to fancybox
Aha. You're right. I guess I was expecting it to fire after the last
slide had been reached. Know of a method for that?

On Jan 7, 1:10 am, JFK <jfk.d...@gmail.com> wrote:
> well, that is normal
> onComplete will be called just right after the content is loaded
> see callback examples herehttp://fancybox.net/home

JFK

unread,
Jan 7, 2011, 1:13:01 PM1/7/11
to fancybox
you may build a jQuery function that compares the currentIndex against
the currentArray.length and when it is bigger or equal to it, fires
your alert
then set that function in the onComplete option

you use those values to build a formatted title like "image 1/ 3" for
instance
see the
$("a[rel=example_group]").fancybox({ ....
example here for reference
http://fancybox.net/js/web.js

Tom

unread,
Jan 12, 2011, 2:15:17 PM1/12/11
to fancybox
Hmm. I'm getting closer. Thanks for the direction. Here's where I'm
at:

function getIndex(title, currentArray, currentIndex, currentOpts) {
var current = currentIndex;
var end = currentArray.length - 1;
if (current == end) {
alert("last image loaded")
$(this).click(function() {
alert("last image clicked")
});
return false;
}
}

$("a[rel=quick_look]").fancybox({
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'speedIn' : 600,
'speedOut' : 200,
'centerOnScroll' : true,
'cyclic' : true,
'titleFormat' : getIndex
});

$("li.quick-look a").click(function() {
$("a#quick-first[rel=quick_look]").trigger('click');
return false;
});

The first alert "last image loaded" is firing as the last image
loads. That's a good thing. But how do I go about setting it up so
when last image is clicked, it fires that other alert "last image
clicked"? Basically, I just want to people able to click on the last
image, have the slideshow close and redirect user to another URL. I
can add that all to the click function there, but I can't seem to get
the click function to fire. Any ideas?

Tom


On Jan 7, 1:13 pm, JFK <jfk.d...@gmail.com> wrote:
> you may build a jQuery function that compares the currentIndex against
> the currentArray.length and when it is bigger or equal to it, fires
> your alert
> then set that function in the onComplete option
>
> you use those values to build a formatted title like "image 1/ 3" for
> instance
> see the
> $("a[rel=example_group]").fancybox({ ....
> example here for referencehttp://fancybox.net/js/web.js

JFK

unread,
Jan 12, 2011, 3:05:20 PM1/12/11
to fancybox
$(this).bind('click',function() {
alert("last image clicked");
});

Reply all
Reply to author
Forward
0 new messages