ckEditor 4.15.1 and setDirty(), isDirty, resetDirty() etc

with a ckeditor in a form like:

elements: [
{
view: ‘ckeditor’,
scroll: ‘auto’,
id: ‘recruitment_brief’,
mode: ‘document’,
name: ‘recruitment_brief’,
css: ‘recruitment-brief’,
contentHeight: 400,
value: ‘’,
barHeight: 80,
toolbarCanCollapse: false,
toolbarStartupExpanded: true,
toolbarHidden: true,
readOnly: akoni.common.readOnly(),
},
{ view: “button”, value: “Abbrechen”, click: onCancel }
]

is there also a posibility to check with isDirty() or setDirty() or do I have to add an ‘onChange’ event?

Thank you in advance…

Michael

Hello @Michael ,

The basic requirements of the isDirty() , setDirty() to work for the form element is that this element has “name” and getValue() / setValue() methods.
When form elements are collected, the form saves the initial values of its controls via the getValue() method of the each element. Then, when calling isDirty() the saved value is compared to the current value, also got via a getValue(). Default comparison is a simple loose inequality operator (!=).
In case of the editor with an empty string as an initial value (as in your code snippet), isDirty() should work fine: Code Snippet .
If some other initial value was provided to the editor and you get true when calling isDirty() with no real changes made, most likely the value from the editor config differs from the one returned by the ckeditor.getData in the editor.getValue().
Ckeditor setData() / getData() work with the html strings, so the issue can be in the provided common JS string as an initial value, however if to provide html string, the comparison in the isDirty() will work properly: Code Snippet .