2013-10-30 31 views
1

我在讨论如何访问我创建的小部件中的特定方法。来自德国Titanium中的示波器链

var foo = { 

    init : function() { 
     $.bar.addEventListener('click', this.handleClick); 
    }, 

    handleClick : function(e) { 
     console.log(this); // TiUIButton { widgetId="Ti.UI.Button:0" ... 
     // I want to call baz() here....How to do that? 
    }, 

    baz: function() { 

    } 
}; 

foo.init() 

问候,并感谢您的帮助,

--marc

+0

只是做:'foo.baz();' –

回答

0

很简单:

var foo = { 

    init : function() { 
     $.bar.addEventListener('click', this.handleClick); 
    }, 

    handleClick : function(e) { 
     console.log(this); // TiUIButton { widgetId="Ti.UI.Button:0" ... 
     // I want to call baz() here....How to do that? 
     // Like this 
     foo.baz(); 
    }, 

    baz: function() { 

    } 
}; 

foo.init()