Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable browsers to "remember" form values when using jquery?

See: http://friendfeed.com/paul/2b7ddce5/jquery-1-3-breaks-bfcache-because-it-binds

I've got a form in my web app, and if the user submits it and presses the browser BACK button the form values are remembered (e.g. any values the user entered).

Once I add jQuery 1.4.2 to the page (e.g. reference it as a script), then this behaviour changes. From what I've read, this happens because jQuery hooks the onunload event, and this is a signal to browsers that the script is not bfcache-aware, so it turns off bfcache.

UPDATE: I looked into this a bit further, and this problem was fixed in jQuery 1.4 it seems. It looks like the problem was caused by the autocomplete plugin I was using, I'll post a resolution if I find one.

like image 773
Alex Black Avatar asked Nov 22 '10 19:11

Alex Black


1 Answers

For my forms I use an on submit handler to save each form elements value in a cookie, and then pre populate the fields with that data (in PHP side) .. This way the for always keeps the info, even if the person closes the window and then goes back to it.. Or gets distracted and clicks on some other page..

like image 68
Alex Avatar answered Nov 11 '22 16:11

Alex