EnablePersistence on two richttexteditors on the same page

Hello,

I'd like to enable the persistence on multiple richtext component which are on the same page.

Unfortunately when I refresh the page, all richtext component get the value of the last edited rich text. Is there anyway to achieve this by keeping the value of each richtext separately?

Thanks a lot,

Yvan



2 Replies

YB Yvan Blancmunier May 15, 2023 09:23 AM UTC

i got it to work by changing the ids on each rt component and including them in an iframe.

But I actually have another question. Is it possible to check how old is the persistent data. I'd like to check, if it's newer than the data stored in the database, the I use the persistent data. If not, I will bind it to the data stored in the database. Is this something one can achieve?

Kind Regards,

Yvan



TJ Theveshwar Jayakumar Syncfusion Team May 19, 2023 09:27 AM UTC

Hi Yvan,

By default, the data persistent in RichTextEditor works based on the local storage mechanism. here, we have passed the key-value pair of date and time while saving the data into the local storage using the unload event to achieve your requirement. Please check the code and sample below,

Code snippet:
ngOnInit() {
    setTimeout(() => {
      window.addEventListener('unload'function () {
        localStorage.setItem('Date'new Date().toString());
      });
    });
  }





In the above image, you can see that both the persisted data and date time are stored in the local storage and you can store that date value into your database.

Regards,
Vinitha

Loader.
Up arrow icon