作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 ExtJs 6 中有一个表单,我需要将提交按钮设置为在文本字段中按下 Enter 键时按下的默认按钮,这里是代码
{
xtype: 'panel',
animCollapse: true,
collapseDirection: 'top',
collapsible: true,
iconCls: 'fa fa-filter',
title: 'By Mac Address',
items: [{
xtype: 'textfield',
id: 'macaddressValue',
itemId: 'macaddressValue',
padding: 10,
fieldLabel: 'Mac Address'
}, {
xtype: 'button',
width: 150,
iconCls: 'fa fa-search',
text: 'Search',
listeners: {
click: 'onSearchClick4'
}
}]
}
我使用了引用资料,但没有成功,我可以使用或查看什么作为潜在的答案
最佳答案
在文本字段中写入一个按键监听器。并调用提交按钮的处理函数。
您可以在下面找到代码。
{
xtype: 'panel',
animCollapse: true,
collapseDirection: 'top',
collapsible: true,
iconCls: 'fa fa-filter',
title: 'By Mac Address',
items: [{
xtype: 'textfield',
id: 'macaddressValue',
itemId: 'macaddressValue',
padding: 10,
fieldLabel: 'Mac Address',
listeners: {
keypress : function(textfield,eventObject){
if (eventObject.getCharCode() == Ext.EventObject.ENTER) {
me.onSearchClick4(); // Call the handler of your Submit button.
}
}
}
}, {
xtype: 'button',
width: 150,
iconCls: 'fa fa-search',
text: 'Search',
listeners: {
click: {
scope : me,
fn : me.onSearchClick4();
}
}
}]}
关于javascript - 如何将提交按钮设置为表单的默认按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37385399/
我是一名优秀的程序员,十分优秀!