Stephen Stephen - 1 month ago 11
jQuery Question

How can I extend a Slick carousel function?

I would like to extend the pause function in slick.
https://github.com/kenwheeler/slick/blob/master/slick/slick.js#L1590

Here is what I have so far, but I am unable to access the pause function with
$.fn.slick.prototype.pause;

(function ($) {
var _original = $.fn.slick.prototype.pause;

function trigger(target, name, relatedTarget) {
target.trigger($.Event(name, { relatedTarget: relatedTarget }));
}

$.extend($.fn.slick.Constructor.prototype, {
pause: function () {
console.log("bleh")
}
});
})(jQuery);


Anyway I could do this?

Answer

If you look at the end of the source code, you'll see that the JQuery exposed function isn't actually the Slick object, but a function using it.

As far as my understanding of this goes, I'd say what you want to extend is enclosed in an inaccessible closure, which renders answers such as this one unfeasible.