[jQuery] Namespacing instance functions (plugins)
Hello,
Couldn't find this discussed elsewhere, but is there a way to safely
namespace your plugin's functions using the $.fn member? An example
usage would be to group functionality into logical modules, but
instead of prefixing every function name with a prefix, one could
simply add the function to an object. Something along the lines of:
(function($) {
$.fn.namespace = {};
$.fn.namespace.method = function(options) {
// iterate over elements
return this.each(function() {
/* manipulated matched element here */
};
};
})(jQuery);
Of course, this doesn't work. Any way to keep plugins from over-
populating the $.fn namespace?