Inplace editor save on browser close or reload

Hello,
I have implemented functions for the inplace editor so I can save the content on browser close or reload. However, it seems that the newer versions have broken it. The code is the following: 
- The component

                <SfInPlaceEditor Mode=RenderMode.Inline
                                  ID="TextEditor"
                                  Type=InputType.RTE
                                  EditableOn=EditableType.Click
                                  SubmitOnEnter="true"
                                  EmptyText="No information provided yet."
                                  Name="RTE"
                                  TValue="string"
                                  [email protected]
                                  Model="@RteModel">
                    <InPlaceEditorEvents TValue="string" OnActionSuccess=@(async e => {
                                                                               this.Description = e.Value.ToString();
                                                                               await this.SaveAsync();
                                                                           })>
                    </InPlaceEditorEvents>
                </SfInPlaceEditor>
-the js code
window.onbeforeunload = function () {
    var textEditor = document.getElementById('TextEditor');
    if (!textEditor) {
        return;
    }

    var editorObj = textEditor_instances[0];
    if (editorObj.enableEditMode) { // To ensure whether editor in editable mode
        editorObj.save(); // Save the editor current value
    }
};

window.addEventListener('popstate', function (event) {
    var editorObj = document.getElementById('TextEditor')_instances[0];
    if (editorObj.enableEditMode) { // To ensure whether editor in ediable mode
        editorObj.save(); // Save the editor current value
    }
}, false);


10 Replies

PM Pandiyaraj Muniyandi Syncfusion Team April 8, 2020 11:41 AM UTC

Hi Ivan, 
 
Greetings from Syncfusion support. 
 
We have validated the reported issue with shared sample code blocks and addressed you are wrongly accessed the component instance. 
  
We suggest you get the component instance by ej2_instances as follows 
  
 
var textEditor = document.getElementById('TextEditor'); 
var editorObj = textEditor.ej2_instances[0]; 
  
var editorObj = document.getElementById('TextEditor').ej2_instances[0]; 
 

If you need further assistance on this, kindly revert to us. 
 
Regards, 
Pandiyaraj 



KI Krasimir Ivanov April 8, 2020 02:06 PM UTC

Hello, yes now it is actually going through the function. However, OnActionSuccess is not invoked for some reason when I am trying to refresh, close or browser back.


PM Pandiyaraj Muniyandi Syncfusion Team April 9, 2020 09:03 AM UTC

Hi Ivan,  
 
Good day to you. 
 
We have validated the OnActionSuccess event not invoked issue, it works properly from our end. We have prepared video for your reference, check it from below mentioned link 
 
Also, we have prepared sample for your reference, get it from below link 
 
Note: In JS, onbeforeunload method not triggered while debug with breakpoints on page refresh, actually it triggered we can ensure it by using console.log(). 
 
Still, if you face the same issue, please modify the above sample to reproduce your issue and revert it to us. This will help us provide a solution at earliest. 
 
Regards, 
Pandiyaraj 



KI Krasimir Ivanov April 26, 2020 03:25 PM UTC

I updated the version to 18.1.0.45 and it works correctly in most cases. However, if you put a breakpoint on line 32 (in the save method in Index.razor) and then run the app in debug mode the first time you click the refresh button on the browser the method is not called. The second, third, etc. work however the first doesn't. 


IS Indrajith Srinivasan Syncfusion Team April 27, 2020 12:21 PM UTC

Hi Ivan,

Good day to you,

We are currently validating the reported query from our end and will update you with further deatils in two business days by 29th April.

Regards, 
Indrajith 



IS Indrajith Srinivasan Syncfusion Team May 8, 2020 01:25 PM UTC

Hi Ivan,

Sorry for the delayed response,
 
 
We have further validated on the reported query and have confirmed Server-side InPlace Editor Trigger Success Event is not Called Properly” as a bug from our end and logged the report for the same, and the fix will be included with our 2020 Volume 1 SP 1 release.

You can now track the current status of the report, review the proposed resolution timeline, and contact us for any further inquiries through this link: https://www.syncfusion.com/feedback/14192/

Regards,
 
Indrajith 



IS Indrajith Srinivasan Syncfusion Team May 14, 2020 02:12 PM UTC

Hi Ivan,

We regret for the inconvenience caused,

We couldn't include the fix with our SP 1 release due to complexity in fixing the reported issue from our end. We will we include the fix with our patch release on the end of May 2020.

Regards,
Indrajith
 



IS Indrajith Srinivasan Syncfusion Team June 1, 2020 12:32 PM UTC

Hi Ivan,  
  
We deeply regret for the inconvenience caused.  
  
Due to the complexity, it is not included in this patch release. We will provide high priority and the fix will be included in the Vol 2 2020 release, which will be expected to be rolled out on end of June 2020. We appreciate your patience until then.  
  
Regards,  
Indrajith 



KI Krasimir Ivanov September 24, 2020 03:41 PM UTC

Hello, 
Is this fixed in version 18.2.0.59?


IS Indrajith Srinivasan Syncfusion Team September 28, 2020 01:49 PM UTC

Hi Ivan,

Sorry for the delay in getting back to you,
 
  
Since the issue occurs only for the first time, it seems complex to validate from our end. The OnActionSuccess event is invoked properly from our end, if called from Blazor. The reported issue occurs only with the JavaScript call of the In-place editor method. On further validation, the event window.onbeforeunload will call the JavaScript in the page for the return call and will not work for the first unload. Hence it works for the second, third after the browser is cached. Check the below links for reference.

https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload
https://stackoverflow.com/questions/31025512/ajax-inside-onbeforeunload-is-not-working-the-first-time
https://stackoverflow.com/questions/40788305/js-not-working-on-first-load-works-after-a-refresh
 

Regards,
 
Indrajith 


Loader.
Up arrow icon