gpt4 book ai didi

javascript - 无法在粘贴事件中获取 ExtJs 4.1 中文本区域字段的值

转载 作者:行者123 更新时间:2023-11-28 08:14:50 25 4
gpt4 key购买 nike

请检查此fiddle 。我正在 ExtJs 4.1 textareafield 中粘贴一些值,但我无法获取该字段的值。请建议如何在粘贴事件中获取值。

Ext.onReady(function () {
Ext.create('Ext.window.Window', {
height: 60,
layout: 'anchor',
minHeight: 60,
width: 200,
items: [{
grow: true,
anchor: '100%',
flex: 1,
enableKeyEvents: true,
xtype: 'textareafield',
id: 'txtFld',
listeners: {
keydown: function (txtArea, e, eOpts) {
//console.log(e.getKey());
if (e.keyCode == 13 && txtArea.value.split("\n").length >= 5) {
console.log('unable to stop :( ');
e.stopEvent();
return false;
}
},
paste: {
element: 'inputEl',
fn: function (event, inputEl) {

if (event.type == "paste") {
console.log('in pasted');

console.log("inputEl.value >> " + inputEl.value);
console.log("inputEl.innerHTML >> " + inputEl.innerHTML);
console.log("inputEl.innerText >> " + inputEl.innerText);
console.log("inputEl.outerText >> " + inputEl.outerText);
console.log("inputEl.outerText >> " + inputEl.outerText);

console.log(' Ext Val >> ' +Ext.getCmp('txtFld').value);

//event.preventDefault();
//return false;
}
}
}
}
}]
}).show();
});

最佳答案

监听器似乎在设置 inputEl 的值之前运行。我发现了一个有点肮脏的解决方法,但对我有用。

delay:1 添加到 paste 监听器。它导致监听器稍后运行 1 毫秒,这显然足以设置该值。我已经在 Chrome@Max OS X 中进行了测试。

关于javascript - 无法在粘贴事件中获取 ExtJs 4.1 中文本区域字段的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23733583/

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