I found that if I run an IsDirty() check on a field value, I will get a "true" return even if the user hasn't enered or changed antyhing in the field. The reason: CKEditor is rewriting code it sees as incomplete, and as a result the field "IsDirty" from the start, because the value has been changed from StartupValue when the object is created.
Here is the code I used to get around this:
I hope this helps someone. This may be contrary to the spirit of FCK since FCK is attempting to start with clean code, but on a a complex form it's not always appropriate to tell the user "hey your page has changed" when he/she doesn't even know what they did - let them at least focus on the editor and start making a change, and the code can be cleaned up on that edit..
Samuel
Here is the code I used to get around this:
/* ----- ckUpdater (detectChange) coding; used because IsDirty() started out "dirty" b/c FCK was rewriting my code ------*/ var oUpd=[]; var oUpdINITIAL=[]; function CKUpdater(field){ if(detectedChange)return false; if(typeof field!=='undefined' && !oUpd[field]){ oUpd[field]=FCKeditorAPI.GetInstance('Description'); //I had to do this because fck editor was immediately rewriting my code if(typeof oUpdINITIAL[field]=='undefined')oUpdINITIAL[field]=oUpd[field].EditorDocument.body.innerHTML } for(var i in oUpd){ //note I am comparing with the intial value *I* got vs. .StartupValue.. if(oUpdINITIAL[i]!=oUpd[i].EditorDocument.body.innerHTML){ detectedChange=true; return; } } setTimeout('CKUpdater()',1000); } //then aftercreating a CKeditor object, I just call this: CKUpdater('Description');
I hope this helps someone. This may be contrary to the spirit of FCK since FCK is attempting to start with clean code, but on a a complex form it's not always appropriate to tell the user "hey your page has changed" when he/she doesn't even know what they did - let them at least focus on the editor and start making a change, and the code can be cleaned up on that edit..
Samuel