I am trying to use the .proxy () method in a jquery plugin. Not sure what is going on, but it does not call methods. I have the following code example:
(function($) { var settings = { } var methods = { init: function(options) { alert('init fired'); $.proxy(methods.strobe,this); return this; }, destroy: function() { }, strobe: function(){ alert('strobe fired'); }, show: function() {}, hide: function() {}, refresh: function() {} }; $.fn.notify = 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.notify'); } }; })(jQuery); $().notify();
I have this jsfiddle for testing: http://jsfiddle.net/CZqFW/
Any input would be appreciated.
source share