Skip to main content

Extending slider prototype, override any function

To override any function without modifying slider core - you may extend they prototype.

Let's assume that you need to know when slider autoplay has stopped permanently. There is public function stopAutoPlay, let's extend it.

jQuery(document).ready(function($) {
// initialize slider as usual and save it's object
var slider = $('.royalSlider').royalSlider({
// options
}).data('royalSlider');

// extend slider object
slider.stopAutoPlay = function( /* optional_arguments */ ) {
// do something there
console.log('slideshow is permanently stopped');

$.rsProto.stopAutoPlay.call(this /* , optional_arguments */ );
};

});

jQuery.rsProto - public variable that holds slider prototype, log it to see what functions do you have. You can extend only public functions. Functions that start from underscore _ may be renamed in build process.