jQuery plugin function in global scope -


nowadays have been learning lot jquery plugin development , jquery . have made simple jquery plugin moved outside initialize() function $.fn.testplugin initialize() function in global scope. question how move outside initialize() function $.fn.testplugin same time make local scope.

plugin:

(function($){     function initialize($obj, color){         $obj.css("color",color);     };            $.fn.testplugin = function(options){        var defaults = {          color: "red"        };        var option = $.extend(defaults, options);         return this.each(function(){         var $this = $(this);           initialize($this, option.color);        });           }; })(jquery); 

your initialize() function not in global scope; explicitly creating closure defined. cannot access initialize() function outside outermost function in posted code.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -