:)
I'm using the NicEdit WYSIWYG editor. The DIV is patched with a hidden textarea field.
The problem is that all changes are just synced onSubmit().
Now I need a way to listen for changes. For example to change backgound color of the field on changing content (inputs) (flagged as unsaved). But there is no addEventListener for changed InnerHTML, as far as I know. So maybe it's possible to use a callback function like a domMutationObserver. But I have no ideas how to deal with that.
js code:
let domField = document.querySelector('.contents .subpage[data-pagename="Index"][data-culture="en-US"] .nicEdit-main');
I can detect the selector of the editor div. So how to detect changes inside this element/node?
I read something about an "observer" to detect dom mutations. Maybe somebody can give me a simple and easy example.
Thx for everything. ;)
EDIT: And I hope we all agree that I won't set an interval (just to save browser performance). But yeah that could be a way. So watching for mutations or changing innerHTML of my DIV element.
pseudo code:
domElement.innerHTML.watch('change', elem => {
elem.classList.add('changed'); //or unsaved
});