gpt4 book ai didi

javascript - 如何将提交按钮设置为表单的默认按钮

转载 作者:行者123 更新时间:2023-12-03 06:53:39 25 4
gpt4 key购买 nike

我在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com