【问题标题】:ajax extjs having problems with up/down methodsajax extjs 在 up/down 方法上有问题
【发布时间】:2013-07-13 06:02:47
【问题描述】:

大家好,我正在尝试在我的窗口中的按钮上添加一个简单的处理程序。处理程序只是将文本文件中的值设置为组合框项 id = 'wildanimal'

  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)
                                                      }
                                         })
                                     }  

但是我收到 Uncaught TypeError: Object [object global] has no method 'up' ... 有没有不使用 .up 的方法来做到这一点?

【问题讨论】:

    标签: ajax extjs


    【解决方案1】:

    这可能会解决您的问题。您的“this”引用是 ajax 函数,而不是您期望的按钮:

    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)
                    }
                });
            }  
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-07
      • 2012-08-06
      • 2023-03-22
      • 1970-01-01
      • 2014-02-26
      相关资源
      最近更新 更多