4 ms·
Jquery.localStorageTextareas
- huggyface 15y agoDepends on Modernizr.js, underscore.js, jQuery 1.7 Is the JavaScript library thing getting a little out of hand? The functionality that this offers is but a few lines of unencumbered code with zero dependencies (obviously gracefully not doing anything if the browser supports it).
- michokest 15y agoI made this for my own project (which uses all those), but you have a point. I just removed the Modernizr dependency. I kept jQuery 1.7. I kept underscore.js for the great _.debounce function.
- egze 15y agoWhat are some real world scenarios when you would need it?
- switz 15y agoAny time you have a textarea element on your page. Imagine you're writing a long response to a blog, and just as you are about to hit Submit, the page crashes. Now you can reload the page and your text will still be there!
- kennu 15y agoIt sounds like an interesting idea for auto-saving article text or similar longer submissions, which are sometimes lost if you accidentally quit the browser or something else goes wrong.
- michokest 15y agoImagine if you're replying a long thoughtful reply to this post and you lose because you close the window, or your browser crashed. Load the page again and it'll be there. We use this for Teambox, where users type long long descriptions for some things.
- mdbilaly2k 15y agoReally a nice feature, helpful in many scenarios...
- ImJasonH 15y agoThis should be a Chrome extension for Firefox plug-in, that automatically adds this feature to any textbox on the web.
- jcassee 15y agoYou mean like Lazarus? Chrome: https://chrome.google.com/webstore/detail/loljledaigphbcpfhfmgopdkppkifgno https://chrome.google.com/webstore/detail/loljledaigphbcpfhf... Firefox: https://addons.mozilla.org/en-US/firefox/addon/lazarus-form-recovery/ https://addons.mozilla.org/en-US/firefox/addon/lazarus-form-...
- emehrkay 15y agoAny reason why it is limited to textareas?
- michokest 15y agoI didn't need it for anything else. Feel free to send a pull request if you find it useful for more things.
- emehrkay 15y agoI probably wont do that, but maybe updating the selector would allow for more form elements to be used (if somebody wanted to use it for more than just textareas) textarea[data-save-id] to form *[data-save-id] I dont even know if that is a valid sizzle selector though
- michokest 15y agoI didn't need it for anything else. Feel free to send a pull request if you find it useful for more things.
- dazbradbury 15y agoReminds me of: http://simsalabim.github.com/sisyphus/ http://simsalabim.github.com/sisyphus/ However, this appears to have more limitations than sisyphus, where you can simply call the library and have all form data saved to local storage: $('form').sisyphus();
- michokest 15y agoWhat a great find! My solution is much more limited but also very lightweight: only textareas, only two scenarios (click or load on demand)
- dazbradbury 15y agoNo problem, it's often hard to find the thing you want, so you just build it. Thanks for sharing and helping others! However, I would say, that for 4kb (minified), sisyphus offers a lot of functionality - and is supposedly cross-browser compatible. If you want to limit it to textareas only, it's not much of a modification. Anyway, just thought I'd point out an alternative, and thanks again for sharing your work!