This is a migrated thread and some comments may be shown as answers.

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

4 Answers 126 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Sambasiva
Top achievements
Rank 1
Sambasiva asked on 08 Aug 2008, 06:19 AM
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.

4 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 08 Aug 2008, 10:11 AM
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.
0
Anthony
Top achievements
Rank 1
answered on 28 Mar 2014, 11:11 PM
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?
0
Anthony
Top achievements
Rank 1
answered on 28 Mar 2014, 11:35 PM
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).

0
Marin Bratanov
Telerik team
answered on 31 Mar 2014, 04:09 PM

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.

 
Tags
Editor
Asked by
Sambasiva
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Anthony
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or