Steven
Steven

Reputation: 867

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?

Upvotes: 0

Views: 1112

Answers (1)

Antoine Combes
Antoine Combes

Reputation: 1454

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.

Upvotes: 1

Related Questions