Closed a2exfr closed 7 years ago
Hmm... I wonder if we should try to sync this with autosaving somehow.
Problem that save come first before section content is updated
Timed autosave might also happen during section updating.
We should generally only allow to save once the section is updated.
We should generally only allow to save once the section is updated.
Lets try it. Becase another error appears time to time. "Do not work ES3" something like that is disappers quickly. that in time of saving
... and we should also disallow making changes during update is running, e.g. using loading(); -> loaded();
strange.... set $section['always_process_values'] to true do not help to render saved values edit : my bad, its saved in section on added
strange.... set $section['always_process_values'] to true do not help to render saved values
did you create a new section with this setting? then it should. its a default value and cannot be changed later, once it is stored false.
Ok, I think I got a good solution - will contribute soon
I also have solution but it not elegant. In short: add additional hidden input with cached content, update its value on section content update, save cached content from this input. That's all. Test it, seems that work good. What you think?
gp_editor.checkDirty() now still compares values with cached values but will only trigger gp_editor.updateSection() in case they differ. But: It will return (boolean)gp_editor.isDirty which will be set to true only by $gp.response.updateContent (when the section's content is actually rewritten).
$gp.response.updateContent will also call (new) gp_editor.resetCache()
gp_editor.isDirty will only be set to false again by gp_editor.resetDirty() which is called automatically by Typesetter's save function after everything is saved.
In order to prevent value changes in the editor UI while gp_editor.updateSection() is in AJAX process, I'll add loading(); and loaded(); to block the editor UI. E.g. when hammering on a number field's arrows, we trigger lots of changes in short time - this could cause issues.
Current implementation seems to work flawlessly.
Actually this is no good
because we saving new values, but content is taken old! After log out, we see old values in section. in source values and cashed content is different
Think we must set var content, after section content is replaced or add in checkdirty aditional condition to save this new replaced content.
edit: or use this
.trigger("CustomSection:updated")
to set check dirty true once more