重置在Sencha Touch中不起作用

Reset does not work a form in Sencha Touch

本文关键字:不起作用 Touch Sencha      更新时间:2023-09-26

我只想在单击表单上的重置按钮时重置所有字段。我尝试了所有的方法,但似乎都不起作用。这是有按钮的类:

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

表单的ID是"jobSearch",名称是"keypads"。你正试图把两者结合起来。

尝试:

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

或:

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

试试这个。它更像ExtJS。

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