I have a div, divDialog, that contains a simple dialog box. It begins life invisible, but at a certain point I make it visible. The page has several other elements on it (menus, etc.) that have event listeners for the click event.
My question is, once divDialog is visible, how can I disable all click events for everything except divDialog? Of course, once divDialog is invisible again, I'd like to restore all listeners to normal behavior.
I read this elegant answer, but it doesn't disable outside clicks, nor is it cross-platform.
I do have a routine that will detect whether a node is an ancestor of another:
function isAncestorOf(ancestor, descendant) {...}
...and that may be necessary in the solution. But I'm having trouble with event listeners, bubbling, capturing, and cross-platform behavior (can't seem to figure it out for IE).
I'm not using jquery on this one; just regular ol' javascript.
Any suggestions?