PDA

View Full Version : view with function and use of this



srxx123
16 Oct 2012, 4:26 AM
Hi,

I have a view with a panel with a function like this:


myfunc: function(v) {
this.getComponent('myfield').setValue(v);
}

I give a callback to this function to a xhr request which calls it in onSuccess like this:

callback('some value').

The problem is, that this is now no longer the panel where my function is defined but some other context from xhr (I think a a window object).

So how can I solve this problem? Somehow I should not use this.getComponent() but me.getComponent(). But how can I define me (I'm creating the view with SA, nothing hand coded here)?

Tim Toady
16 Oct 2012, 8:47 AM
How are you doing your ajax request? Ext provides a property called scope that you can specify as "this" when you call it and the callback will maintain the same scope as the the function the request was called in.