0

I 've got an issue with jQueryCycle2,

The event 'cycle-initialized' never firing

I saw a solution in an old post. Cycle2 Initialization events not firing

    $(document).on('cycle-initialized', $('#mySlider'), function(){
        // EVENT IS FIRED CORRECTLY
    });

But this solution work for only one Slider, I've got 2 slider on my homepage. Is there anyway to use correctly cycle-initialized, cycle-post-initialize or cycle-pre-initialize in order to initialize severals jqueryCycles

thanks

Community
  • 1
  • 1
Jaybe
  • 329
  • 2
  • 11

2 Answers2

0

So run it on the slideshows instead of document

$('#mySlider').on('cycle-initialized', function(){
    // EVENT IS FIRED CORRECTLY
});

If they both have a similar class you could cover both with:

$('.someClass').on('cycle-initialized', function(){
    // EVENT IS FIRED CORRECTLY
});

This code should be placed before the initial .cycle() command, if not then cycle-initialized will fire before it can be captured; which will make it seem like it never fires.

EDIT: Not sure why this is getting downvotes, I have a working example of it right here

FiLeVeR10
  • 2,155
  • 1
  • 12
  • 13
  • put it that way, wont fire the event because the object was already initialized , the correct one is like the @Jaybe wrote, but instead he probably needs to change to a class instead of a id – Jose De Gouveia Oct 28 '15 at 09:08
  • @Joyal that's what I put in the comment; that it has to be run before the initial .cycle or it will make it seem like it never fires, – FiLeVeR10 Nov 06 '15 at 15:58
0

Please make sure to add event listener before the cycle is actually initialised consider the below answer from FiLeVeR10 'cycle-initialized' must be called, before calling 'cycle'

$('.show').each(function(i) {
    //initialized
    $(this).on('cycle-initialized', function(e, opts) {
        alert('OMG, it hit initialized on '+i+'...');
    })
    //slideshow
    .cycle({
        carouselFluid:      true,
        slides:             'a',
        pauseOnHover:       true
    });
});
Nafsin Vk
  • 519
  • 4
  • 9