Hi, I'm new in JS/jQuery development and i need your help about a question : where really to place private and public functions ?
I saw various possibilities on the net, but two seems to be identical. For example, public function. The first possibility : ;(function($) { var $.fn.pluginName = function(options) { var opts = $.extend({}, $.fn.pluginName.defaults, options); // public function inside $.fn.pluginName function var $.fn.pluginName.publicFunction = function(args) { // CODE ... }; // CODE ... return this.each( function() { // CODE ... }); }; })(jQuery); The second possibility : ;(function($) { var $.fn.pluginName = function(options) { var opts = $.extend({}, $.fn.pluginName.defaults, options); // CODE ... return this.each( function() { // CODE ... }); }; // public function inside (function($) { ... })(jQuery) var $.fn.pluginName.publicFunction = function(args) { // CODE ... }; })(jQuery); What is the best ? Are they different ? The same question existe about private functions. First : ;(function($) { var $.fn.pluginName = function(options) { var opts = $.extend({}, $.fn.pluginName.defaults, options); // private function inside "$.fn.pluginName" function var privateFunction = function(args) { // CODE ... }; // CODE ... return this.each( function() { // CODE ... }); }; })(jQuery); And the second possibility : ;(function($) { var $.fn.pluginName = function(options) { var opts = $.extend({}, $.fn.pluginName.defaults, options); // CODE ... return this.each( function() { // CODE ... }); }; // private function outside "$.fn.pluginName" function var privateFunction = function(args) { // CODE ... }; })(jQuery); Really thanks for your help, --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---