簡體   English   中英

重置在Sencha Touch中不起作用

[英]Reset does not work a form in Sencha Touch

我要做的就是單擊表單上的“重置”按鈕時,它將重置所有字段。 我已經嘗試了所有方法,但是似乎沒有用。 這是其中包含按鈕的類:

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中,我具有處理reset方法的代碼://這是我想到的一種方法。 但是顯然這是行不通的。 我已經嘗試了整個谷歌搜索,但找不到解決方案。

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”,名稱為“ keyboards”。 您正在嘗試將兩者結合起來。

嘗試:

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

要么:

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

嘗試這個。 它有點像ExtJS。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM