EditLive! 9 Documentation : isDirty Method

This method returns a string depicting whether the current contents of EditLive! have changed since the content was initially loaded into the editor. 

Prior to version 8.1 this function had no return value and the function was asynchronous. While asynchronous use is still supported, since version 8.1 this function can now be used synchronously with a return value.

Syntax

JavaScript
String editliveInstance.isDirty([jsFunct]);

Parameters

jsFunct

This parameter is optional.

The JavaScript function that receives the string (TRUE or FALSE) depicting whether the contents of EditLive! have changed since first being initialized.

Returns

The value TRUE if the contents of EditLive! have changed since first being initialized.

Example Synchronous (EditLive 8.1+)

Calling isDirty synchronously returns a string depicting whether the current contents of the editor have changed. This example retrieves the dirty status of the editor and then displays it in a JavaScript alert dialog. The name of the EditLive applet is editlive_js.

var editorIsDirty = editlive_js.isDirty();

Example Asynchronous (EditLive 8.0+)

When calling isDirty asynchronously you must provide a JavaScript function as the callback parameter for the isDirty method. In this example the dirtyStatus function receives the dirty status of the editor. The name of the EditLive applet is editlive_js.

editlive_js.isDirty('dirtyStatus');

The dirtyStatus function receives the dirty status of the editor and displays a JavaScript alert dialog based on the recieved status.

function dirtyStatus(status) {
		if(status == "true"){
				alert("Content Has Changed");
			}
		else {
		   		alert("Content Has NOT Changed");
			}
	}