[英]How to bind click and double click events on the same element in CKeditor
我在CKeditor click事件和雙擊事件方面遇到問題。 當前,我將單擊事件和雙擊事件綁定到CKEditor dom。
editor.on('doubleclick', function (evt) {
console.log("doubleclicked");
//Some ajax calls
}, null, null, 999 );
editor.on('click', function (evt) {
console.log("clicked");
//Some ajax calls
}, null, null);
上面的代碼有一個問題,當我雙擊該元素時,它也會首先觸發click事件。 當我雙擊該元素時,兩個代碼都會執行。
以上情況的CKEditor有解決方案嗎?
我的問題與CKeditor插件有關。 因此,我必須為單擊和雙擊綁定適當的(內置)事件。
嘗試這個。 它會工作。 對於CKeditor,您可以用該行editor.on('doubleclick', function (evt) {
editor.on('dblclick', function (evt) {
替換行editor.on('doubleclick', function (evt) {
function singleClick(e) {
console.log('single click');
}
function doubleClick(e) {
console.log('double click');
}
editor.on('dblclick', function (evt) {
$(this).data('double', 2);
doubleClick.call(this, evt);
//Some ajax calls
}, null, null, 999 );
editor.on('click', function (evt) {
var that = this;
setTimeout(function() {
var dblclick = parseInt($(that).data('double'), 10);
if (dblclick > 0) {
$(that).data('double', dblclick-1);
} else {
singleClick.call(that, evt);
}
}, 300);
//Some ajax calls
}, null, null);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.