-
11 Oct 2012 4:45 AM #1
listener context is different ?
listener context is different ?
I am not sure what is going on here.
It seems the object context is different, I don't know enough to be able to see why. I am used to C++ etc where the context is well defined... I don't know whats wrong.
init: function() {
this.callParent();
Ei.sys.Appdata.addListener( 'onClientConfigChange', this.onClientConfigChange);
this.setStartTitle('opal'); // this call works
},
setStartTitle:function(newTitle){
console.log('set title ' + newTitle)
},
onClientConfigChange:function(){
this.setStartTitle('test'); // this call fails withUncaught TypeError: Object [object Object] has no method 'setStartTitle'
},
-
11 Oct 2012 1:43 PM #2
help
help
No response as yet, I think this is a simple problem for those experienced in this area, please help.
BTW I have tried a number of combinations but nothing works.
Is it not possible to pass a function property to an event callback and have the callback function know the object instance it is associated with.
-
11 Oct 2012 3:36 PM #3
Its failing because thats not the correct scope. If you put a break point on "this.setStartTitle" in your onClientConfigChange function, you can see that "this" has no method "setStartTitle" which is the error message you are seeing. You can pass a scope in when you add your listener.
The third parameter is the scope.
Ei.sys.Appdata.addListener( 'onClientConfigChange', this.onClientConfigChange, this);
-
11 Oct 2012 11:28 PM #4
Thanks
Thanks
It works with that paramater, Thank you.
I have found my biggest issue with ExtJs is that the library is hard to browse for functions and arguments, the lack of proper code completion and classbrowsing is taking the fun out of what could be a world beater...
I have yet to find a good editor and doubt one exists, this is probably more of a Javascript issue as much as ExtJs.
After trying Sencha Architect, Eclipse, Vi .... I have settled on Netbeans. But am still decades behind the C++ world.
If you know of something that helps on this side please let me know.


Reply With Quote