Abel
Abel

Reputation: 2511

how to use a defined event handler function instead of anonymous function in plugins (slick slider)

I know how to use a event handler functions for click, scroll and other default events. Currently I am using a slider plugin called slick slider and its working fine, I want to replace my event handlers with defined functions instead of anonymous function.

$(slick).on('afterChange', function(slick, currentSlide) {
    //doing some thing
}

I want it to be

$(slick).on('afterChange', {slick, currentSlide}, myFunctionName);

But it is showing error, what I am missing here?

Upvotes: 0

Views: 300

Answers (1)

Satpal
Satpal

Reputation: 133443

Just pass the function reference

$(slick).on('afterChange', myFunctionName);

and accept parameters in the function i.e.

function myFunctionName(slick, currentSlide){}

Upvotes: 1

Related Questions