2010-04-08 48 views
1

我重視我的CKEditor像這樣CKEditor的模糊和對話

editor = CKEDITOR.instances.fck; 
editor.on("blur",function(e){ 
    alert("hello"); 
}); 

你跟我的模糊函數?

現在,當我點擊閃光燈按鈕時,編輯器模糊並導致警報顯示。

如何我阻止這種情況發生,仍然可以得到警報出現其他時候一樣,當用戶離開編輯區

再次感謝

回答

0

當你點擊一個按鈕樣的模糊事件被解僱在出現對話框時向上點擊後閃爍。鼠標在編輯器外部移動後,您想要的模糊事件就會發生。這很髒,但通過跟蹤鼠標狀態,你可以實現你的目標。

$(function() { 
    var mouseState = 0; 
    $(document).mousedown(function(){ mouseState = 1; }); 
    $(document).mouseup( function(){ mouseState = 0; }); 

    var editor = CKEDITOR.instances.editor1; 
    editor.on("blur", function(e) { 
     if (mouseState == 1) console.log("blur"); 
    }); 
}); 
0

我現在也有這個問題。

我的解決辦法是換一個倉內的編輯器,讓我們把它ID =「持有」,並結合本次活動:

var isMouseOverEditor = false; 
$('#holder').hover(function(){ 
    isMouseOverEditor = (e.type=='mouseenter' ? true : false); 
}); 

在後來編輯的模糊事件:

editor.on("blur", function(e) { 
    if (!isMouseOverEditor) return; 
    // your code here for "real" blur event 
}); 

這不是最好的解決方案,但它是一個很好的解決方法,可以使用。看起來,編輯器的模糊事件綁定到編輯器本身。這意味着當編輯區域模糊時,事件就會被觸發。

希望這可以幫助任何人有這個問題。

6

只要我們正在研究黑客,我喜歡用這個來解決這個問題。關鍵是CKE使用iFrame作爲他們的下拉式控件(顏色選擇器和背景顏色,字體大小,字體類型)

editor.on("blur", function(e) { 
    if ($(document.activeElement).get(0).tagName.toLowerCase() != "iframe") { 
     // your code here for "real" blur event 
    } 
});