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. Image for the cookie policy date
close icon

Saving on browser back or refresh

Hello,

How can I save the content of the editor when somebody clicks the browser back or refresh. Currently, when I click outside of the component it saves the new value, however that is not true for the mentioned cases.

Krasimir

1 Reply

PM Pandiyaraj Muniyandi Syncfusion Team November 21, 2019 11:50 AM UTC

Hi Krasimir, 
 
Greetings from Syncfusion support. 
 
We have validated your requirement and its default functionality of browser. We can achieve this requirement from application end by calling In-place Editor - save() public method in JavaScript window.onbeforeunload event callback as follows. 
 
 
Note: onbeforeunload trigger when leaving from current page (refresh too). 
 
Index.js 
 
Add index.js file with below code blocks and save it in wwwroot folder of your application. Then add this JS file reference into _host.cshtml 
 
 
window.onbeforeunload = function () { 
    var editorObj = document.getElementById('TextEditor').ej2_instances[0]; 
    if (editorObj.enableEditMode) { // To ensure whether editor in ediable mode 
        editorObj.save(); // Save the editor current value 
    } 
}; 
 
 
We have prepared sample for your reference, get it from below link 
 
Regards, 
Pandiyaraj 


Loader.
Live Chat Icon For mobile
Up arrow icon