simsalabim/sisyphus

Option to cancel/discontinue saving form data?

Closed this issue · 2 comments

I discovered that if I set the timeout low enough, and my server takes a few seconds to respond on a form submit, that Sisyphus can sometimes re-save the form data after the submit handler has fired. It looks like this:

  • Timer causes form data to save
  • User submits the form, which causes the saved data to be released
  • Server takes a long time to respond
  • Timer causes form data to save again

The next time I visit the form, then, there is saved data in the browser that is loaded. In many instances, that's fine, but not if there have been changes to the server data used to pre-load the form fields.

Increasing the timeout value helps, because it reduces the likelihood that another timed save will happen while the form is submitting, but it can still happen.

What I'd like to do is cancel the form protection when the form is submitted, but I haven't been able to get this to work. Mostly, I've been trying to mess with self.settings.options. My hope was that setting it to 0 would cause the timer-based saving to stop, but instead, it causes it to save repeatedly in rapid succession (I used some console logging to determine that).

Any suggestions to hack this in, or interest in adding something like a stopSaving method?

Thanks for the report, I'll think how to sort it out. The issue will get more complicated if we add that form can be submitted via ajax (which means that the form protection should be renewed afterwards with no page reload).

I think that in current version it does not happen...