Reputation: 9459
I'm attempting to trigger a function when an element is removed from a contenteditable div. eg. when the user backspaces and the element is removed.
I've tried the following which works, but not for the elements inside the contenteditable div:
$(document).bind("DOMNodeRemoved", function(e)
{
alert("Removed: " + e.target.nodeName);
});
How else can this be done?
Upvotes: 2
Views: 198
Reputation: 13198
There isn't a great way to do this AFAIK. Best I know is to cache the mark-up before editing begins and then compare current mark-up with cached mark-up on keydown (testing for backspace – keycode 8). Trigger custom event if you detect a full element deletion. Not great, requires a lot of micromanagement, but works.
Upvotes: 1