Created
March 20, 2013 16:42
-
-
Save bryanpaluch/5206191 to your computer and use it in GitHub Desktop.
localStorage all the things!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define([ | |
| localStorageHook, | |
| ], function(LocalStorageHook){ | |
| LocalStorageHook.hook(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #callform.row.center | |
| label Phone or Email | |
| input.stored#address(name="address", type="text", placeholder="Enter Phone or Email") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define([ | |
| 'jquery', | |
| ], function($){ | |
| var hook = function(){ | |
| //Test if we have Local Storage | |
| if(localStorage){ | |
| function init(){ | |
| $.each($('.stored'), function (){ | |
| input_name = $(this).attr('name'); | |
| if(localStorage[input_name]){ | |
| $(this).val(localStorage[input_name]); | |
| } | |
| }); | |
| } | |
| init(); | |
| $('.stored').keyup(function(){ | |
| localStorage[$(this).attr('name')] = $(this).val(); | |
| }); | |
| } | |
| } | |
| return {hook:hook} | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment