当 ajax 调用成功时,我需要更新 sencha 模板。示例代码如下
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));
}
}
);
}
});
错误控制台
this.getTpl is not a function
[Break On This Error]
this.setHtml(this.getTpl().apply(response.responseText));
我success
需要更新模板,但问题是 this.getTpl 在内联函数内部未定义success:function
。它是在 之后定义的initcomponent
。我需要在里面调用它success
。有任何想法吗??