簡體   English   中英

在ExtJS 4中捕獲HtmlEditor內容的變化

[英]Catch change in content of HtmlEditor in ExtJS 4

我想在用戶更改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進行測試,我從這篇文章中獲得了其他信息。

看起來有textarea用於編輯源代碼。 與html中的任何其他字段一樣,此字段僅在模糊后觸發更改事件(HtmlEditor似乎依賴於此事件)。 您可能應該綁定到其他事件,例如keydown ,然后根據按下的鍵,觸發適當的事件。 你可以在渲染處理程序中執行:

{
    xtype: 'htmleditor',
    listeners: {
        render: function(){
            this.textareaEl.on('keydown', function() {
                this.fireEvent('sync', this, this.textareaEl.getValue());
            }, this, { buffer: 500 });
        },
        sync: function(sender, html){
            debugger;
        }
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM