I am looking to add functionality to my Quill rich Text boxes where if the user makes a change to Rich Text box then they are prompted to either remain or discard changes if they try to navigate away from the page. I am creating my text-change event as follows:
quill.on('text-change', function (delta, oldDelta, source) {
quillChanged = true;
});
Which is fine. If there is a change to the text then the event is fired, my variable is changed and I handle things from there. However, the Event Trigger is also fired when the rich Text boxes are auto-populated on Page Load.. Which I don't want.
I have seen a WPF example with a similar (non Quill) issue, and the answer there was to use a this.IsLoaded
check. I'm wondering if there is something similar here for quill or if there are any other more practical ideas? I have thought about creating hidden fields to store the original page-load values for each text box but that is all starting to feel a bit messy.
This turned out to be a problem with the way the fields were being populated - not the trigger itself.
The code to populate the editors was:
$j('.ql-editor', container)[0].innerHTML = htmlInputString;
This was triggering the event. I simply changed this to be
quill.clipboard.dangerouslyPasteHTML(htmlInputString, 'api');
And now the HTMl gets applied as expected and the trigger is not fired when the field is populated.