3

ユーザーがExtJS4で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を使用してこれをテストしており、この投稿から他の情報を入手しました。

4

1 に答える 1

2

ソースの編集に使用される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;
        }
    }
}
于 2011-12-07T06:59:53.533 に答える