gpt4 book ai didi

javascript - 更改事件对 selectfield 不起作用?

转载 作者:行者123 更新时间:2023-11-30 16:35:39 26 4
gpt4 key购买 nike

我对 Sencha 触摸选择字段更改事件感到震惊。通常的更改事件工作正常。但如果像这样的选项值,

{
xtype: 'selectfield',
label: 'Choose one',
options: [{text: 'First Option', value: 1},
{text: 'First Option', value: 2},
{text: 'Third Option', value: 3}],
listeners : {
change : function (selectField, newValue, oldValue)
{
console.log(newValue);
}
}
}

当这种情况下值不同但显示值相同时,更改事件不起作用。请帮助完成这个问题。

最佳答案

这是 Sencha 的问题。你可以检查这个链接

https://www.sencha.com/forum/showthread.php?304198-Select-field-not-firing-change-event-on-same-text-but-different-value .

但是如果你需要这样做,那么你可以用这种方式,把它写在启动函数中。

Ext.override(Ext.field.Input, {
setValue: function (newValue) {
var oldValue = this._value;

this.updateValue(this.applyValue(newValue));

newValue = this.getValue();
this.onChange(this, newValue, oldValue);

return this;
}
});

关于javascript - 更改事件对 selectfield 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32737646/

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