I'm extending the jquery.contentcarousel plugin, and I've reached a specific point where I'm defining new functions via __prototype__
. I shrunk the code down to demonstrate the essential part:
(function($) {
var aux = {
navigate : function(){
//...
},
}
methods = {
init : function( options ) {
return this.each(function() {
var $el = $(this);
//THIS IS THE SLIPPERY LINE:
$el.__proto__.scrollOneLeft = function() {
aux.navigate( -1, $el, $wrapper, $.extend(settings, {sliderSpeed: 10, sliderEasing: ''}), cache );
};
});
}
}
$.fn.contentcarousel = function(method) {
if ( methods[method] ) {
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof method === 'object' || ! method ) {
return methods.init.apply( this, arguments );
} else {
$.error( 'Method ' + method + ' does not exist on jQuery.contentcarousel' );
}
};
})(jQuery);
This works on the modern browsers, but the problem is that $el.__proto__
is not working in IE9 and IE10 (yet). I'm not a jQuery Ninja, so I guess that this isn't the proper solution anyway.
So my question is, how would you define a new method properly in this scenario?