【发布时间】:2012-02-18 01:55:56
【问题描述】:
我想要做的就是当我单击表单上的重置按钮时,它会重置所有字段。我已经尝试了一切,但似乎没有用。这是其中包含按钮的类:
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);
【问题讨论】:
-
您是否正在查看 form.query('#jobSearch').getComponent('keywords') 给您的信息?我觉得你的 var 形式和你的查询是错误的。
标签: javascript sencha-touch extjs