malsup / cycle2

2nd gen cycling
899 stars 237 forks source link

buildPagerLink API is never fired #157

Open sbosell opened 11 years ago

sbosell commented 11 years ago

The documentation states that all API events can be replaced via the cycle-bootstrap event like so:

$( '#mySlideshow' ).on( 'cycle-bootstrap', function( e, optionHash, API ) {
    // replace "advanceSlide" method with custom impl
    API.advanceSlide = function( numberOfPositions ) {
       // custom implementation
    }
});

The buildPagerLink api does NOT seem to work. It is defined as: function( slideOptionHash, slide )

So:

$( '#mySlideshow' ).on( 'cycle-bootstrap', function( e, optionHash, API ) {
    // replace "advanceSlide" method with custom impl
    API.buildPagerLink =function( slideOptionHash, slide ) {
       // alert('fired');
    }
});
$('#mySlideShow').cycle();

The buildPagerLink never seems to be fired.

Here is a jsfiddle example: http://jsfiddle.net/lucuma/zyhrK/2/

malsup commented 11 years ago

Yeah, this is a sequencing issue with the event delegation. For now you can bind at the document instead of the slideshow (until I fix it):

$(document).on('cycle-bootstrap', function( e, opts, API ) {
    API.buildPagerLink = function(opts, slideOpts, slide) {
        // your impl
    }
});
sbosell commented 11 years ago

Thanks, if you just point me at a file or a place I'm more than happy to send a pull request with the fix. I've always enjoyed using this plugin and the prior version and don't mind putting a little time in to give back if that's something you are interested in.

aleemb commented 10 years ago

+1

jakeparis commented 9 years ago

It's worth noting to others finding this that the event binding must be outside of the jQuery load function.