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));
テンプレートを更新する必要がありますが、問題は、 this.getTplsuccess
がインライン関数内で未定義になっていることsuccess:function
です。の後に定義されinitcomponent
ます。私はそれを内部で呼び出す必要がありますsuccess
。何か案は??