editor.SetClean() -to complement editor.IsDirty()

Last post 04-04-2014, 9:19 AM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  04-03-2014, 5:16 PM 80211

    editor.SetClean() -to complement editor.IsDirty()

    I have logic that uses editor.IsDirty() to determine whether to auto-save user updates.

    If IsDirty() returns 'true' then I use client-script to grab the editor text and save it to the server.

    I would like a way to then cause editor.IsDirty() to return false (because the changes have been saved). I was looking for something like editor.SetClean(), but found nothing. Is there a way I can use client-side script to cause editor.IsDirty() to return false?

     

    Thanks. 

  •  04-04-2014, 9:19 AM 80224 in reply to 80211

    Re: editor.SetClean() -to complement editor.IsDirty()

    Hi jeff330ci,

     

    You can achieve your requirement by the code below.  Value GetContentVersion will be changed when fire the new IsDirty. If is the same IsDirty, then do not need to save the content.

     

    1. <script type="text/javascript">  
    2.     var savedver=0;  
    3.     function save()  
    4.     {  
    5.         var editor1 = document.getElementById('<%= Editor1.ClientID%>').editor;  
    6.         var newdver = editor1.GetContentVersion();  
    7.         if (editor1.IsDirty())  
    8.         {  
    9.             if (newdver == savedver) {  
    10.                 //no changed  
    11.                 alert("no change, so do not save content");  
    12.             }  
    13.             else {  
    14.                 //save content  
    15.                 alert("save content");  
    16.                 savedver = editor1.GetContentVersion();  
    17.             }  
    18.         }  
    19.     }  
    20. </script>  
     

    Regards,

     

    Ken 

View as RSS news feed in XML