2013-07-12 41 views
1

嘿傢伙所以我想在我的窗口中的按鈕上添加一個簡單的處理程序。該處理器僅設置從一個文本文件中的值的組合框項ID =「wildanimal」ajax extjs有上/下方法的問題

items: [{ 
    itemId: 'button1', 
    xtype: 'button', 
    text: 'click the button', 
     handler: function(){ 
         Ext.Ajax.request({ 
      url: 'stuff.txt', 
      method: 'GET', 
      success: function (result){ 
      this.up('Ajax').down('wildAnimal').setValue(result.responseText) 
                 } 
             }) 
            } 

但是我收到一個遺漏的類型錯誤:對象[對象全局]有沒有方法「上」 ......有沒有如何在不使用.up的情況下做到這一點?

回答

0

這可能會解決您的問題。你'這'參考是對阿賈克斯功能,而不是像你所期望的按鈕:

items: [{ 
    itemId: 'button1', 
    xtype: 'button', 
    text: 'click the button', 
     handler: function(theButton){ 
      Ext.Ajax.request({ 
       url: 'stuff.txt', 
       method: 'GET', 
       success: function (result){ 
        theButton.up('window').queryById('wildAnimal').setValue(result.responseText) 
       } 
      }); 
     } 
+0

哦,我知道了!謝謝 :) –