Reputation: 23
I am working in extjs4. How do I call member function (hellotest) within another member function (showSubject)?
I am trying to add a call to hellotest
in the tabchange
event of subjectBar
(which is part of the showSubject
function). I tried to use scope the function call using this, but this didn't work and I got the following error: object[object object] error undefined function
Here is my some code:
Ext.define('Am.DnycontentcategoriesController', {
extend: 'Ext.app.Controller',
init: function () {
this.control({
//'viewport > panel >Contentcategories':
'Contentcategories': {
render: this.showSubject,
}
});
},
hellotest: function () {
console.log("inside hello test function");
},
showSubject: function () {
//console.log(this.hellotest());
subjectBar.on('tabchange', function () {
//here I am getting error
this.hellotest();
var tab = subjectBar.getActiveTab();
--------
});
},
Upvotes: 2
Views: 8133
Reputation: 74096
set the scope
to this
:
showSubject: function () {
subjectBar.on('tabchange', function () {
this.hellotest();
var tab = subjectBar.getActiveTab();
}, this);
}
The scope (this reference) in which the handler function is executed. Defaults to the
Element
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.EventManager-method-on
Upvotes: 4