14

こんにちは、ユーザーが tinyMCE テキストエリアへの書き込みを終了し、外側のどこか (onBlur) をクリックしたときに、いくつかの処理を実行したいと考えています。これまでのところ、私は試しました:

$('#id_topic_text_parent').live('blur',function(){
    alert('asd')
//I saw #id_topic_text_parent in firebug, it is span containing the tiny mce
});

また

$('#id_topic_title').blur(*and*)live('blur...
tinyMCE.activeEditor.blur(*and*)live('blur...

しかし、それはうまくいきません。
手伝ってくれませんか。

4

6 に答える 6

16

http://www.tinymce.com/wiki.php/api4:event.tinymce.Editor.blurによると

これは私のために働く

setup : function(ed) {
    ed.on('blur', function(e) {
        alert('blur');
    });
},
于 2014-06-04T03:00:59.720 に答える
10

このアプローチを使用して問題を解決できます。tinymce を初期化するときは、setup パラメータを次のように設定します (内部tinyMCE.init({...})

...
theme: "advanced",   // example param
plugins = 'code',    // example param
setup : function(ed) {
    ed.onInit.add(function(ed, evt) {

        var dom = ed.dom;
        var doc = ed.getDoc();

        tinymce.dom.Event.add(doc, 'blur', function(e) {
            // Do something when the editor window is blured.
            alert('blur!!!');
        });
    });
},
cleanup: true,      // example param
...
于 2011-04-08T11:52:22.580 に答える
1

使ってください

function myCustomOnChangeHandler(inst) {
        alert("Some one modified something");
        alert("The HTML is now:" + inst.getBody().innerHTML);
}

tinyMCE.init({
        ...
        onchange_callback : "myCustomOnChangeHandler"
});

参照: http://www.tinymce.com/wiki.php/Configuration:onchange_callback

この関数は、ユーザーが領域を「ぼかす」と呼び出されます。

于 2012-10-09T13:12:02.540 に答える
1

これを使用してぼかしの外部ツールバーを閉じましたが、動作しているようです(現時点では FF でのみテストされています)。

function showHideBar(sho,aid) { // aid=id not used
    if(sho) {
        $( ".mceToolbar,.mceExternalClose" ).show();
    } else {
        $( ".mceToolbar,.mceExternalClose" ).hide();
    }
}

tinyMCE.init({

    // ....

    theme_advanced_toolbar_location: "external",
    resize : true,
    setup : function(ed) {
        ed.onInit.add(function(ed, event) {
            $(ed.getBody()).blur(function() {
                // alert("blur");
                showHideBar(false,ed.id);
            });

            $(ed.getBody()).focus(function() {
                // alert("focus");
                showHideBar(true,ed.id);
            });

        });
    },

    // ....

}
于 2013-06-10T17:06:07.523 に答える
0

編集:

$('#id_topic_text_parent textarea').live('blur', function() {
   alert('asd');
});

#id_topic_text_parent スパンの HTML を投稿できますか?

$('#id_topic_text_parent').find('textarea').blur(function(){ alert('asd'); });

于 2011-04-08T10:29:29.543 に答える