How to know the content in the editor been changed.?

5 posts, 0 answers
  1. Sambasiva
    Sambasiva avatar
    45 posts
    Member since:
    May 2008

    Posted 08 Aug 2008 Link to this post

    Hi,

    I am using RadEditor to display my content from database. On a client side button click event, i should know whether the content in the editor been modified or not. I have used the following code which is working when user tries to add/modify the content using key input. But same was not  working when user drags and drops the content in the editor. I have used mousedown event but it is not firing.

    I have taken variable"hdnIsContentChange" which is initially set to false, when user tries to modify the data i am comparing the intial content of the editor with new value which i put in hidden variables.

    "onkeyup" is the only event is working, the rest are all not working.

    var hdnIsContentChange = false;
    function Editor_OnClientLoad(Editor, args)
    {
            Editor.attachEventHandler ("onmouseup", ContentChange);  //not working
            Editor.attachEventHandler ("onmousedown", ContentChange);//not working
            Editor.attachEventHandler ("ondrag", ContentChange);//not working
            Editor.attachEventHandler ("onchange", ContentChange);//not working
            Editor.attachEventHandler ("onkeyup", ContentChange);//working
           
            function ContentChange()
            {
                $get("hdnNewContent").value = radEditor.get_html();
                
                 if($get("hdnInitialContent").value != $get("hdnNewContent").value)
                        get("hdnIsContentChange").value = true;
           }
     }

    Please let me whether this approach is correct or already is there any way to know the content been modified by using editor's built-in functions or properties.
  2. Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 08 Aug 2008 Link to this post

    Hi Sambasiva,

    The following three events work properly on my side:
    Editor.attachEventHandler ("onmouseup", ContentChange); - working
    Editor.attachEventHandler ("onmousedown", ContentChange); -  working
    Editor.attachEventHandler ("onkeyup", ContentChange); - workign

    Here is how to attach the ondrag event
    ondrag ->
    var element = document.all ? Editor.get_document().body : Editor.get_document();
    $telerik.addExternalHandler(element, "drop", ContentChange);

    and the onchange event -> OnClientSelectionChange

    For your convenience I have attached my test project and video demonstrating my test.

    You can find more information in this help article: http://www.telerik.com/help/aspnet-ajax/editor_attacheventhandler.html.


    Best regards,
    Rumen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Anthony
    Anthony avatar
    2 posts
    Member since:
    Mar 2014

    Posted 28 Mar 2014 in reply to Rumen Link to this post

    Does RAD Editor have this functionality built-in now (years later), or should we still manually add the suggested code to check for the different ways that content may have been modified?
  5. Anthony
    Anthony avatar
    2 posts
    Member since:
    Mar 2014

    Posted 28 Mar 2014 in reply to Anthony Link to this post

    This option seems to work well for me: Once OnClientLoad has been triggered, store in a variable the value of editor.get_html(true). Then when checking if the contents has been modified, compare the original value to editor.get_html(true).

  6. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 31 Mar 2014 Link to this post

    Hello Anthony,

    RadEditor offers a Track Changes feature similar to MS Word's: http://demos.telerik.com/aspnet-ajax/editor/examples/trackchanges/defaultcs.aspx if that's what you are looking for. If you need to know if the content has changed at all (i.e., what is commonly known as an isDirty flag for the form/control) - you would need to implement it manually to match your needs.


    Regards,

    Marin Bratanov
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017