jQuery Plugin Namespace

jquery

Solution

(function($) {
    $.fn.amtec = function () {
        var jq = this;
        return {
            foo1: function(){
                return jq.each(function(){});
            },

            foo2: function(){
                return jq.each(function(){});
           }
       }
    };
})(jQuery);

Problem

How do I create a jQuery plugin so that I can use namespaces in my plugin ? ``` $("#id1").amtec.foo1(); $("#id1").amtec.foo2(); ``` None of these seem to work. ``` (function($) { var amtec = { $.fn.foo1 : function(){ return this.each(function(){}); }, $.fn.foo2 : function(){ return this.each(function(){}); } }; })(jQuery); ``` ``` (function($) { $.fn.amtec = function(){ var foo1 = function(){ return this.each(function(){}); }; var foo2 = function(){ return this.each(function(){}); }; } })(jQuery); ```

Original source