我正在上双击编辑表的TD
元素:暂时禁用所有当前活动的jQuery的事件处理程序
$(document).on("dblclick", "#table>tbody>tr>td.cell", function(e) {
if (e.which != 1 || e.shiftKey || e.altKey || e.ctrlKey)
// need left button without keyboard modifiers
return;
reset_selection();
var editor = document.createElement("div");
editor.setAttribute("contenteditable", "true");
editor.innerHTML = this.innerHTML;
this.innerHTML = '';
// this.style.padding = 0;
this.appendChild(editor);
$(document).on("*", stub);
editor.onblur = function() {
// this.parentNode.setAttribute("style", "");
this.parentNode.innerHTML = this.innerHTML;
sys.editor = null;
$(document).off("*", stub);;
};
editor.focus();
});
function stub(e) {
e.stopImmediatePropagation();
return false;
}
但是,当我双击可编辑的DIV中的文本,则双击事件传播到父母td造成不良后果。还有其他的事件(select
,mousedown
等),我想要防止,所以为他们每个人写一个存根并不看好我。
有没有一种方法来禁用所有当前活动的jQuery的事件处理程序之后允许它们?或者有人停止将可编辑div的所有事件传播给其父母?
如果'td'的父母之一也有一些处理程序会怎样?我是否也为他们每个人做了一个存根? – warvariuc 2013-02-13 08:57:15
@warwaruk:不需要,'false'停止传播。 – 2013-02-13 08:58:47
我有'