This is a migrated thread and some comments may be shown as answers.

[Solved] Un-synchronized editor value when autosave

3 Answers 84 Views
Editor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Vasile
Top achievements
Rank 1
Vasile asked on 16 Oct 2011, 12:15 PM
Hello,

I have a page using an MVC Editor control (actually many of them), I want to perform some automatic autosave of the edited content in the form.

To do this I use the jQuery serialize() function of the form element, then I post the serialized form information to server using jQuery post(). It work fine, excepting that the serialize function will not serialize the "real" value of the last focused Editor control, it is like the value in the hidden field associated with the Editor control does not get updated until the control looses its focus. Because of this my autosave feature will save older information than it is actually in the editor.

Is there any way of forcind the editor controls to flush their "real" value, from the visual, into the hidden field, from where is read by the jQuery form serialize()?

Thanks,
Vasile M

3 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 18 Oct 2011, 08:31 AM
Hi Vasile,

Calling the update() client-side method before you serialize the form should update the textarea value and fix the problem:

    $("#editor").data("tEditor").update()

This should happen automatically and might be a problem only if the user is typing when you are trying to serialize the form.

Kind regards,
Alex Gyoshev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Vasile
Top achievements
Rank 1
answered on 20 Oct 2011, 07:21 PM
Hello Alex,

Thank you for your answer, the solution you suggested works.

Two apects:
I have checked and by default it will not work even if I let the control at rest .. no typing at all when autosave happens, it will still don't get the value from the visual, without explicitly calling update().
Is this update() operation something internal to your control? I mean I tried to find something like it in the chm file before asking here, and I did not found any reference of it in the Editor documentation, perhalps would be a good idea to have a review of that information too.

Best regards,
Vasile M
0
Alex Gyoshev
Telerik team
answered on 21 Oct 2011, 07:17 AM
While the update() method is not internal, it is rarely used and thus, wasn't properly documented. That has been fixed for upcoming releases. Thanks for pointing this out.

I just checked where update() is called, and indeed -- it is called upon several occasions (when needed), but not in the one I described. It seems that this is the proper behavior, because it is costly (in terms of performance) to serialize the editor value more than necessary -- so calling update() is the way to go.

Regards,
Alex Gyoshev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Editor
Asked by
Vasile
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Vasile
Top achievements
Rank 1
Share this question
or