simsalabim / sisyphus

Gmail-like client-side drafts and bit more. Plugin developed to save html forms data to LocalStorage to restore them after browser crashes, tabs closings and other disasters.
http://sisyphus-js.herokuapp.com
MIT License
1.99k stars 221 forks source link

Class based fields & persist after submit. #168

Closed regiside closed 1 year ago

regiside commented 1 year ago

Can't really find any documentation for this plugin, not sure if it used to be on http://sisyphus-js.herokuapp.com/ but there's nothing there now.

I'm wanting to save only form fields with a specific class into storage and I'd like them to persist after the form has been submitted as they will be some basic info about the user that will always be the same.

Anyone know if there's a way to do this with sisyphus?

regiside commented 1 year ago

Found the documentation on WayBack Machine. https://web.archive.org/web/20200927100957/http://sisyphus-js.herokuapp.com/

Was able to achieve the desired affect using the "autoRelease" & "excludeFields" parameter combined with the :not() css selector...

jQuery( "form" ).sisyphus( {
        excludeFields: jQuery( "hidden,*:not(.remember *)" ), // Skips hidden fields and any field that's not in a container with the class "remember"
        autoRelease: false, // Stops the fields from being reset upon form submission
    } );