I'm creating a jQuery plugin that that is rather large in scope. In fact, the plugin technically consists of a few plugins that all work together.
(function($){
$.fn.foo = function(){
//plugin part A
}
$.fn.bar = function(){
//plugin part B
}
$.fn.baz = function(){
//plugin part C
}
}(jQuery))
Is it possible to namespace jQuery plugins such that the minor plugins could be functions of the larger plugin
$.fn.foo.bar = function(){}
$.fn.foo.baz = funciton(){}
This would keep from polluting the jQuery function namespace. You could then call the plugins like
$('#example').foo()
$('#other_example').foo.bar()
The issue I have run into when trying this out myself is that the functions declared as properties of the foo() plugin function don't have their references to 'this' set properly. 'this' ends up referring to the parent object and not the jQuery object.
Any ideas or opinions would be appreciated.
-Matt