0
當Ajax調用成功時,我需要更新sencha模板。示例代碼是像下面在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 inline函數裏面success:function
不確定。它在initcomponent
之後定義。我需要打電話給success
。有任何想法嗎??