We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Auto-save contents of ejRTE

Thread ID:

Created:

Updated:

Platform:

Replies:

118788 Apr 9,2015 03:14 PM Apr 15,2015 12:23 AM JavaScript 3
loading
Tags: ejRTE
Randy Craven
Asked On April 9, 2015 03:14 PM

Hello,

Is it possible to save the contents of an ejRTE control automatically when the control loses focus?  Alternately, would it be possible to save the contents of the control periodically, say every 15 seconds? 

The blur event would be the obvious choice but the ejRET doesn't expose a blur event.

The change event would be the other obvious choice here but I believe that event will fire too often;  unless the changes could be cached and submitted when the user leaves the page.

Would it be possible to catch an event triggered when the user leaves the page, and if the control has unsaved changes, save them at that point?  For example, the change event could set a flag indicating that there are unsaved changes, and the "save" button would set that flag to false.

Thank you,

Randy


Manikandan Mariappan [Syncfusion]
Replied On April 13, 2015 02:21 AM

Hi Randy,
Thanks for using Syncfusion products.
Query: Is it possible to save the contents of an ejRTE control automatically when the control loses focus?
We have analyzed your requirement and we can achieve it by binding the click event to the iframe element. Also we need to bind document click event for capture the iframe focus out. Since focusout and blur events cannot be cached within the iframe, when we click the document we can get the html string from the RTE instance to save it. Please refer the below code.


[JavaScript]

var rteObj, isFocus, data;

$(function () {

$("#rteSample").ejRTE({

width: "850px",

showFooter: true,

});

rteObj = $("#rteSample").data("ejRTE");

$("#" + rteObj.element[0].id + "_Iframe").contents().on("click", function () {

//get html string in iframe textarea using getHtml() method

if (!isFocus) data = rteObj.getHtml();

//maintain flag variable for element focused or not.

isFocus = true;

});

//when click the document or any other popup element append in body the document click will triggered

$(document).click(function (e) {

//validate the iframe is focused in previously or not, then made any changes in html string

if (isFocus) {

alert("content saved");

isFocus = false;

}

});

});


For your convenience, we have prepared a simple sample based on your requirement. You can also download the attached sample from the following location.
Sample: Sample

Please let us know if you have any queries.
Regards,
M.Manikandan


Randy Craven
Replied On April 13, 2015 09:09 AM

Hello,

Thank you for this answer.

Randy

Manikandan Mariappan [Syncfusion]
Replied On April 15, 2015 12:23 AM

Hi Randy,

Thanks for the update

Please get back to us if you would require any further assistance.

Regards,
M.Manikandan

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;