simsalabim/sisyphus

Enable / disable auto-save

Anguel opened this issue · 10 comments

Hi,

I need to allow the user to enable / disable auto-saving of the form through a button on the page. Can this be achieved through onSave() or is there any way to dynamically register / unregister a form with Sisyphus? I tried calling manuallyReleaseData() in onSave() but this does not seem to ba a good idea and slows down the script.
Thanks.

Anguel

I have already some code for that. Will send it to you during the day.

Cool, thanks. I was thinking about setting some variable in local storage and then reloading the whole page and running sisyphus() only if the variable is set properly but this is probably too much trouble as my form is on tabs :(

Very nice! I hope this will be merged into Sisyphus soon. Thank you once again.

@gabrieljenik : Once again, thank you very much. Now I have an autosave checkbox which sets a variable that is read in your extremely useful onBeforeSave() function and actually defines if autosave will take place or not. Unchecking the autosave checkbox will also call $('#myform').sisyphus().manuallyReleaseData(). Additionally, if the user has disabled the checkbox but decides to reenable autosaving at some point and has entered some data in between I call $('#myform').sisyphus().saveAllData() when he checks the checkbox. Do you think this is safe to do?

Why do you need to release the data? IN regard to "safety" I don't see any thread... do you see something to fear about?

Actually, I am adding the checkbox for users who want more "privacy", maybe they are on some public PC and do not want all their form data to stay on that PC, therefore I release the data when they uncheck the box. I asked if it is ok to call saveAllData() directly because I don't have much experience with JavaScript and I don't want to break anything :)
BTW, another problem is when the browser is in "safe browsing mode" - browser says it supports local storage and data is saved but will get lost when the private tab is closed :( There seems to be no way to actually tell if browser is in private mode AFAIK and warn the user...

Calling saveAllData() seems good idea.
About private mode, wouldn't know about that. May be you can put some kind of warning message or bubble message near the checkbox.

Yes, I will put a warning. Not the best solution, but at least the user cannot sue me for losing his data ;)))
Thank you once again! @simsalabim : onBeforeSave() is a must have function :)