changing dom problem fixed, dom mutation observer added to call ContextMenus()

This commit is contained in:
arnau
2016-08-17 11:04:40 +02:00
committed by GitHub
parent ae1ba1b47f
commit 30facc9263

View File

@@ -12,8 +12,31 @@ class2context(
);
*/
/* 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
document.body.innerHTML+="<div id='contextMenus'></div>";