Skip to content

Instantly share code, notes, and snippets.

@hanigamal
Created June 15, 2013 12:45
Show Gist options
  • Save hanigamal/5788011 to your computer and use it in GitHub Desktop.
Save hanigamal/5788011 to your computer and use it in GitHub Desktop.
jquery record
if (jQuery)
(function(jQuery){
jQuery.extend(jQuery.fn, {
record: function(options){
jQuery(this).each(function(){
var settings = jQuery.extend({
}, options);
var _this = $(this);
load(_this, true);
_this.on('blur change', function() {
load(_this);
});
});
},
clearRecord: function(){
var name = generateName(this);
localStorage.setItem(name, '');
},
clearAllRecord: function(){
Object.keys(localStorage).forEach(function(key){
if (/^(record)/.test(key)) {
localStorage.removeItem(key);
}
});
}
})
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment