I am trying to set contents of the editor dynamically through SetData() and then immediately calling ResetIsDirty() so that the editor doesn't say dirty unless user changes the content himself. But what is happening is that calling ResetIsDirty() immediately after setting data doesn't seem to work. I modified a sample file in samples/html folder to test this which I have posted below. To test it just press the button 'Check IsDirty()' it should say false but it says true.
I am trying to set Content this way because it'll be fetched through ajax on change of certain form element.
Not sure what I am doing wrong.
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>FCKeditor - Isdirty</title> <link href="../sample.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="../../fckeditor.js"></script> <script type="text/javascript"> function FCKeditor_OnComplete( editorInstance ) { var oEditor = FCKeditorAPI.GetInstance('FCKeditor1'); oEditor.SetData('<b>Changed</b>'); ResetIsDirty(); } function CheckIsDirty() { // Get the editor instance that we want to interact with. var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ; alert( oEditor.IsDirty() ) ; } function ResetIsDirty() { // Get the editor instance that we want to interact with. var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ; oEditor.ResetIsDirty() ; alert( 'The "IsDirty" status has been reset to ' + oEditor.IsDirty() ) ; } --> </script> </head> <body> <form action="../php/sampleposteddata.php" method="post" target="_blank"> <script type="text/javascript"> <!-- var sBasePath = document.location.href.substring(0,document.location.href.lastIndexOf('_samples')) ; var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ; oFCKeditor.BasePath = sBasePath ; oFCKeditor.Value = '<p>This is some <strong>sample text<\/strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor<\/a>.<\/p>' ; oFCKeditor.Create() ; //--> </script> <br /> <input type="submit" value="Submit" /> </form> <div> </div> <hr /> <div id="eMessage"> </div> <div> </div> <div id="eButtons"> <input type="button" value="Check IsDirty()" onclick="CheckIsDirty();" /> <input type="button" value="Reset IsDirty()" onclick="ResetIsDirty();" /> </div> </body> </html>