Javascript 重置在Sencha Touch中不起作用
我想做的就是当我点击表单上的重置按钮时,它会重置所有字段。我什么都试过了,但似乎不起作用。下面是包含按钮的类:Javascript 重置在Sencha Touch中不起作用,javascript,sencha-touch,extjs,Javascript,Sencha Touch,Extjs,我想做的就是当我点击表单上的重置按钮时,它会重置所有字段。我什么都试过了,但似乎不起作用。下面是包含按钮的类: App.views.HomeIndex = Ext.extend(Ext.form.FormPanel,{ floating: true, scroll: 'vertical', itemId: 'jobSearch', centered: true,
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”,名称为“keyboards”。你想把两者结合起来
尝试:
或:
试试这个。它更像ExtJS
var form = Ext.ComponentQuery.query('#jobSearch .form')[0];
form.reset();
您正在检查form.query('#jobSearch').getComponent('keywords')给您的是什么?我觉得您的var表单和查询是错误的。它说:无法调用未定义表单的方法“slice”。查询给出:TypeError:对象没有方法“reset”和文档。表单给出无法调用未定义表单的方法“reset”
document.forms['keywords'].reset();
var form = Ext.ComponentQuery.query('#jobSearch .form')[0];
form.reset();