Reset does not work a form in Sencha Touch

对着背影说爱祢 提交于 2019-12-24 09:27:42

问题


All I want to do is when I click the reset button on my form it resets all fields. And I have tried everything but it does not seem to work. Here is the class that has the button in it:

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',
                           }                                                   
                            ]
                    }]

In my App.js I have the code to handle the reset method: //this is one way I thought of doing it. But obviously it does not work. I have tried googling all over but couldnt find a solution.

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

回答1:


Your form's ID is "jobSearch", the name is "keyboards". You're trying to combine both.

Try:

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

or:

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



回答2:


Try this. It's a bit more ExtJS like.

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


来源:https://stackoverflow.com/questions/8993284/reset-does-not-work-a-form-in-sencha-touch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!