Whenever I call checkDirty() I am always getting true. Run the example below and just click the destroy button.
$(document).ready(function() {
CKEDITOR.config.autoUpdateElement = false;
CKEDITOR.on('contentDom', function (event) {
event.editor.resetDirty();
});
CKEDITOR.on('instanceReady', function (event) {
event.editor.on('contentDomUnload', function (destroyevent) {
alert('isdirty: ' + destroyevent.editor.checkDirty());
});
});
$("#item_ckeditor").ckeditor();
$("#item_docompare").on("click", function (event) {
var $textarea = $("#item_ckeditor"),
editor = $textarea.ckeditorGet();
editor.destroy();
});
});
UPDATE
I have a new isdirty function here that will return an accurate value for if the user has changed the content in the CKEditor. This will not always return true and will still work with the element attributes being automatically sorted.
Original
Looks like there was a space added in the content automatically by the CKEditor so checkDirty() always returned true. I wrote my own function that ignores case and trims the spacing that was added automatically here.
This works perfectly fine, UNLESS you set allowedContent to true and disable the ACF. The new problem is that CKEditor sorts the attributes on elements which causes check for modified content to not work properly.
I logged a separate question here to find out how to disable sorting of element attributes.