mirror of
https://github.com/arnaucube/class2context.git
synced 2026-02-07 19:26:44 +01:00
changing dom problem fixed, dom mutation observer added to call ContextMenus()
This commit is contained in:
@@ -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
|
//creates the div where the context menus will place
|
||||||
document.body.innerHTML+="<div id='contextMenus'></div>";
|
document.body.innerHTML+="<div id='contextMenus'></div>";
|
||||||
|
|||||||
Reference in New Issue
Block a user