在 ExtJS 4 中捕获 HtmlEditor 内容的变化
我想捕获用户在 ExtJS 4 中更改 HtmlEditor 内容的时间。我尝试了同步、更改和推送事件,但都没有成功。每当获得焦点时,同步似乎就会被触发,但不会触发更改,而且我不知道是什么原因导致推送被触发。
谁能告诉我当用户更改 HtmlEditor 的内容时会触发哪个事件?
谢谢
编辑: 我尝试过以下代码,但它对我不起作用,有什么想法吗?
init: function() {
this.control({
'htmleditor[name="reportHtmlEditor"]': {
render: this.addKeyHandler
}
});
},
addKeyHandler: function(field) {
// This gets called fine on the component render
var el = field.textareaEl;
if (Ext.isGecko) {
el.on('keypress',
function() {
// Do Stuff, which never gets called
}, this, { buffer: 100});
}
if (Ext.isIE || Ext.isWebKit || Ext.isOpera) {
el.on('keydown',
function() {
// Do Stuff, which never gets called
}, this, { buffer: 100});
}
},
有关更多信息,我正在使用 Firefox 来测试这一点,并且我从 这篇文章。
I want to capture whenever the user changes the content of an HtmlEditor in ExtJS 4. I have tried the sync, change, and push events all with no success. Sync seems to be fired whenever focus is gained, change isn't fired, and I can't tell what causes push to be fired.
Can anyone tell which event is fired when the user changes the content of an HtmlEditor?
Thanks
Edit:
I have tried the following code which does not work for me, any ideas?
init: function() {
this.control({
'htmleditor[name="reportHtmlEditor"]': {
render: this.addKeyHandler
}
});
},
addKeyHandler: function(field) {
// This gets called fine on the component render
var el = field.textareaEl;
if (Ext.isGecko) {
el.on('keypress',
function() {
// Do Stuff, which never gets called
}, this, { buffer: 100});
}
if (Ext.isIE || Ext.isWebKit || Ext.isOpera) {
el.on('keydown',
function() {
// Do Stuff, which never gets called
}, this, { buffer: 100});
}
},
For some more information, I am using Firefox to test this, and I got the other information from this post.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来有用于编辑源代码的文本区域。该字段与 html 中的任何其他字段一样,仅在模糊后触发更改事件(HtmlEditor 似乎依赖于该事件)。您可能应该绑定到其他事件,例如
keydown
,然后根据按下的键,触发适当的事件。您可以在渲染处理程序中执行此操作:It looks like there is textarea used for editing source. This field, like any other in html, fires change event only after blur (HtmlEditor seems to rely on this event). You should probably bind to other event eg
keydown
and then depending on key pressed, fire appropriate event. You can do it in render handler: