English 中文(简体)
在 encha 上访问父对象
原标题:accessing parent object on sencha

我需要在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));

sucess i 上,我需要更新模板,但问题在于此 。 getTpl in unfreed in in in inline 函数 sucess: fope 。 它定义在 init party 之后。 我需要在 sucess 中调用。 有什么想法吗?

最佳回答

它不是真正的父母。你不能旅行到DOM得到它,但是...

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));
       var me = this;
         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); 
                  me.setHtml(me.getTpl().apply(response.responseText));
            }                       
        } 
        ); 
    }
});    

去查查关闭情况吧

问题回答

暂无回答




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签