I need to update sencha template when ajax call will be successful. The sample code is like below
Ext.define('casta.view.Intro', {
extend: 'Ext.tab.Panel',
tpl: '<p> {username} </p>',
initComponent: function(){
//Be sure to use the var keyword for planet earth, otherwise its declared as a global variable
//var planetEarth = { name: "Earth", mass: 1.00 };
//this.setHtml(this.getTpl().apply(planetEarth));
Ext.Ajax.request(
{
waitMsg: 'Bitte warten...',
url: 'http://localhost:8000/api/casta/user/?format=json',
success:function(response,options){
//var responseData = Ext.util.JSON.decode(response.responseText);
this.setHtml(this.getTpl().apply(response.responseText));
}
}
);
}
});
Error console
this.getTpl is not a function
[Break On This Error]
this.setHtml(this.getTpl().apply(response.responseText));
On success i need to update the template but the problem is that this.getTpl in undefined inside the inline function success:function. It is defined after initcomponent. I need to call that inside success. Any ideas??
Its not really the parent. You can’t travel up the dom to get it, but…
Go read up on closures.