Try // Add an event listener console.log( 'HandlerDef: '+this.__handleButton ); button1.addListener("execute", this.__handleButton, this ); ^^^
On Tue, 8 Dec 2009, balage42-qoox...@yahoo.com wrote: > > Hello! > > I try to use a member function as a callback for my P2P Ajax function. > However, the function is always "undefined". Here is the relevant code of my > application: > > > --------------8<------------------------------------------- > > > main : function() > { > [...] > // Create a button > var button1 = new qx.ui.form.Button("First Button", "edemo/test.png"); > > // Document is the application root > var doc = this.getRoot(); > > // Add button to document at fixed coordinates > doc.add(button1, {left: 120, top: 50}); > > // Add an event listener > console.log( 'HandlerDef: '+this.__handleButton ); > button1.addListener("execute", this.__handleButton ); > }, > > __fillTable : function( pRequest ) { > alert( pRequest ); > }, > > __handleButton : function(e) { > var hrq = new edemo.AjaxTools(); > > console.log( 'Callback: '+this.__fillTable ); > hrq.sendXMLHTTPRequest( '<QD_FETCH_TEST/>', this.__fillTable, null, > false ); > } > > --------------8<------------------------------------------- > > Here the "HandlerDef" trace prints the right method and it is successfully > assigned to the event handler, OTOH, when calling it and tracing the > "callback" function, it returns undefined. > > I am sure I missed some vital aspect of the OO framework, but can't see why > doesn't sees the function? Or the this is "lost" (refers to another object) > for a function when called as an event handler? > > Thanks, > Balage > -- Oetiker+Partner AG tel: +41 62 775 99 03 (direct) Fritz Zaucker +41 62 775 99 00 (switch board) Aarweg 15 +41 79 675 06 30 (mobile) CH-4600 Olten fax: +41 62 775 99 05 Schweiz web: www.oetiker.ch ------------------------------------------------------------------------------ Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev _______________________________________________ qooxdoo-devel mailing list qooxdoo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel