Created
June 15, 2013 12:45
-
-
Save hanigamal/5788011 to your computer and use it in GitHub Desktop.
jquery record
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
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