simon-reynolds / jquery.dirty

https://simon-reynolds.github.io/jquery.dirty/
MIT License
38 stars 19 forks source link

Not working with rich text editor fields #74

Open gtu-myowin opened 2 years ago

gtu-myowin commented 2 years ago

Hi, first of all, thank you very much for the handy plugin. It is really useful and I found it from a stack overflow answer.

My form has a rich text editor fields (CK Editors). Your plugin can detect the dirtiness of all other fields but those rich text editors. Is there any attributes to be set to make it work with rich text editors or it just isn't implemented? If it an unimplemented feature, is there a work around?

Thanks!

EPGDigital-MW commented 2 years ago

After CKeditor is initialised, you need to add an event:

// add change event to set is dirty on the form
editor.model.document.on('change:data', () => {
    // find closest form to the textarea element
    element.closest('form').dirty('setAsDirty');
});