arnaucube
arnaucube/class2contextPublic Self-hosted repository
changing dom problem fixed, dom mutation observer added to call ContextMenus()
arnau idoctnef@openmailbox.org
Wed, 17 Aug 2016 11:04:40 +0200
commit

30facc9263108e6125cff6b3651e356ed7cad265

parent

ae1ba1b47f7f6e89942cbcd250207a0d941e0ee9

1 files changed, 23 insertions(+), 0 deletions(-)

jump to
M class2context.js → class2context.js

@@ -12,7 +12,30 @@ [["option1", "functionoption1()"], ["option 2","functionoption2()"]]

); */ +/* testing this, not necessary +$( document ).ready(function() { + $(document).on('contextmenu', function (e) { + //e.preventDefault(); + ContextMenus(); + }); +});*/ + +/* MUTATION OBSERVER +--detect changes in dom, and re-asign context menus*/ +// select the target node //MUTATION DOM +var target = document.body; +var mutNum=0; +var observer = new MutationObserver(function(mutations) { + console.log("class2context.js: mutation of dom, num." + mutNum); + mutNum++; + ContextMenus(); +}); +// configuration of the observer: +var config = { attributes: true, childList: true, characterData: true }; +// pass in the target node, as well as the observer options +observer.observe(target, config); +/* </MUTATION OBSERVER */ //creates the div where the context menus will place