Sencha Touch中的重置不起作用 [英] Reset does not work a form in Sencha Touch

查看:134
本文介绍了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:按钮',文字:'提交',itemId:'submitBtn',ui:'action',
}
]
}]
pre>

在我的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);


解决方案

尝试这个。这是一个更多的ExtJS喜欢。

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


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

解决方案

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

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

这篇关于Sencha Touch中的重置不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆