SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2006
    Location
    Dubrovnik, Croatia
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript (jQuery) object reference help

    Hi to all.

    I have this problem see the code :

    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

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2006
    Location
    Dubrovnik, Croatia
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Solution :

    Code:
    $.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


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •