An event is a notification that occurs in response to an action, such as a text change in editor, or as a result of the user clicking the toolbar button while editing the document. An event handler is code written in javascript language, that receives control when the corresponding event occurs.

RichTextEditor exposes number of events that you can subscribe to. By registering event handlers, you can interact with it once the editor is loaded and running. In RichTextEditor, there are three event registration models to register event handlers:

Global Events

Global events are broadcast to all editors in the page, triggering any handlers which may be listening.

<script type='text/javascript'>
function RichTextEditor_OnLoader(loader)
{
}
function RichTextEditor_OnCoreLoad(loader)
{
}
function RichTextEditor_OnLoad(editor)
{
    alert(editor._config.uniqueid);
}
function RichTextEditor_OnTextChanged(editor)
{
    alert(editor._config.uniqueid);
}
</script>

Using config object event Property

RichTextEditor_OnLoader automatically receives an asynchronous loader object. A loader is responsible for loading editor necessary libraries, layout information and asynchronously save data into cache. You can get _config object from the loader, so can execute custom actions to change the configuration.

<script type='text/javascript'>
function RichTextEditor_OnLoader(loader)
{
	var config=loader._config;
	config.OnCoreLoad=function()
	{
	}
	config.OnLoad=function(editor)
	{
	}
	config.OnTextChanged=function(editor)
	{
	}
}
</script>

Using editor.AttachEvent Method

The editor.AttachEvent( ) method requires two parameters:

editor.AttachEvent("event", functionReference);

The event parameter is the "on" version of the event name, while the function reference is just like the kind you assign to an object event handler property. The combination of AttachEvent( ) and DetachEvent( ) allows scripts to enable and disable scripted functionality as desired.

Example:

<script type='text/javascript'>
function RichTextEditor_OnLoad(editor)
{
	editor.AttachEvent("TextChanged",function()
	{
	});
	editor.AttachEvent("ExecCommand",function()
	{
	});
}
</script>


Send feedback about this topic to CuteSoft. © 2003 - 2014 CuteSoft Components Inc. All rights reserved.