I'm coding my own jQuery plugin, based on http://docs.jquery.com/Plugins/Authoring
(function($)
{
var methods =
{
publish : function(options)
{
var settings =
{
title : 'Publish'
}
var obj = $(this);
var opt = $.extend(settings, options);
return this.each(function()
{
//some code here
});
}
};
$.modal = 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');
}
};
})(jQuery);
Now the problem is if I don't use: $.fn.modal = function(method)... An error shows: Too much recursion. I want to use: $.modal so then I can call it like: $.modal(); How can I use a lot of methods with their own options and without element like $(element)?
Thanks