【问题标题】:Reset does not work a form in Sencha Touch重置在 Sencha Touch 中不起作用的表单
【发布时间】:2012-02-18 01:55:56
【问题描述】:

我想要做的就是当我单击表单上的重置按钮时,它会重置所有字段。我已经尝试了一切,但似乎没有用。这是其中包含按钮的类:

App.views.HomeIndex = Ext.extend(Ext.form.FormPanel,{
                    floating: true,
            scroll: 'vertical',
                    itemId: 'jobSearch',
            centered: true,
            modal: true,
            hideOnMaskTap: false,
            items: [{  
            xtype: 'textfield',
            itemId: 'keywords',
            label: 'Keywords',
            labelAlign: 'top',
            labelWidth: '100%',
            name: 'keywords'
            },{  
            xtype: 'textfield',
            label: 'Job Title',
            itemId: 'jtitle',
            labelAlign: 'top',
            labelWidth: '100%',
            name: 'jtitle'
            },{
            .... //more xtypes here
                     ,
                dockedItems: [{
                        xtype: 'toolbar',
                        itemId: 'toolbar',
                        dock: 'bottom',
                        height: '36',
                        items: [
                            { xtype: 'button', text: 'Reset',itemId: 'resetBtn',
                            },
                            { xtype: 'spacer'},
                            { xtype: 'button', text: 'Submit',itemId:'submitBtn',ui: 'action',
                           }                                                   
                            ]
                    }]

在我的 App.js 中,我有处理重置方法的代码: //这是我想到的一种方式。但显然它不起作用。我试过用谷歌搜索,但找不到解决方案。

this.homeView.query('#resetBtn')[0].setHandler(function(){
         var form = this.el.up('.x-panel');
         //form.down('.x-input-text[name=keywords]').setValue(' ');
    form.query('#jobSearch').getComponent('keywords').reset();              
        });


            });

    Ext.reg('HomeIndex', App.views.HomeIndex);

【问题讨论】:

  • 您是否正在查看 form.query('#jobSearch').getComponent('keywords') 给您的信息?我觉得你的 var 形式和你的查询是错误的。

标签: javascript sencha-touch extjs


【解决方案1】:

您的表单 ID 是“jobSearch”,名称是“keyboards”。您正在尝试将两者结合起来。

试试:

form.query('#jobSearch').reset();

或:

document.forms['keywords'].reset();

【讨论】:

  • form.query 给出:TypeError: Object has no method 'reset' and document.forms given Cannot call method 'reset' of undefined
【解决方案2】:

试试这个。有点像 ExtJS。

var form = Ext.ComponentQuery.query('#jobSearch .form')[0];
form.reset();

【讨论】:

  • 它说:无法调用未定义的方法“切片”
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-13
  • 2012-09-19
相关资源
最近更新 更多