Javascript (jQuery) object reference help

Hi to all.

I have this problem see the code :


(function($){
	$.fn.my_plugin = function(options){
		return this.each(function(){
			(new $.MyClass(this, options));
		});
	}

	$.MyClass = function(active_item, options) {
            var containers = new Array();
            containers.push(new $.Type(this));
             
            function bark() {
                alert('wuf wuf');
            }
	}

	$.Type = function(referer) {
          referer.bark();
	}

})(jQuery);

Now, problem is here referer.bark() i can’t send object $.MyClass as reference to next object $.Type and call methods. Can someone help, please.

Thank you

Solution :


$.MyClass = function(active_item, options) {
            var containers = new Array();
            function bark() {
                alert('wuf wuf');
            }

            containers.push(new $.Type(this));
	}

	$.Type = function(referer) {
          referer.bark();
	}


Method is not reachable because it’s defined bellow, that’s why it doesn’t exist. Ordering is important :slight_smile: