Kuldeep Daftary
Kuldeep Daftary

Reputation: 621

Call a function after all slides in jquery cycle are loaded

I'm trying to call a function after all slides in jquery cycle slider are loaded. on the options page of plugin's website http://jquery.malsup.com/cycle/options.html I found out an option called after which can be used to call a function after each slides are loaded. but I want a function to be called when all slides are loaded and not each slides.

I added alert("hello") in onAfter(), and I see alert hello after every pager clicks. which i really dont want.

Following cycle initialization is used by me.

    $('#lb_main-slide').cycle({ 
            fx:     'fade',
            speed:  '100', 
            timeout: 0, 
            startingSlide: index,
            pager:  '#lb-slidethumbs', 
            pagerAnchorBuilder: imagepager2,
            after: onAfter,
            requeueOnImageNotLoaded: true
            });

Is there any possible way where I can call a single function once all slides are loaded successfully ?

Thanks in Advance.

Upvotes: 1

Views: 2714

Answers (2)

Jamel Toms
Jamel Toms

Reputation: 4565

I was having the same problem. But I read about there being different types of functions in JavaScript. I realized that I was trying to pass in a reference to a global function to the 'after' attribute. That did not work.

Try doing something like this:

    $('#images').cycle({
         timeout: 5000,
         fx:'fade',
         after: (function() {
             MyClass.performNow();
         })
    });

Upvotes: 1

Kuldeep Daftary
Kuldeep Daftary

Reputation: 621

Well to solve this problem I called my function in core jquery.cycle.all.js file, in

function buildPager(els, opts)

after

opts.updateActivePagerLink(opts.pager, opts.startingSlide, opts.activePagerClass);

So I called my function after cycle's pager was built. And it worked for me perfectly.

Thanks.

Upvotes: 1

Related Questions