Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // jQuery plugin to easily implement autosave
- //
- //
- //
- //
- ;(function($) {
- $.fn.typed = function(settings) {
- var config = {
- 'callback': function(){},
- wait : 750
- };
- if (settings) $.extend(config, settings);
- this.each(function(){
- $(this).attr('old-val', $(this).val());
- var that = this
- function save(){
- var val = $(that).val()
- var old_val = $(that).attr('old-val');
- if (val != old_val) {
- config.callback.call(that)
- $(that).attr('old-val', val )
- }
- }
- var t;
- $(this).keydown(function(){
- clearTimeout(t)
- })
- $(this).keyup(function(){
- clearTimeout(t)
- t = setTimeout(save, config.wait);
- })
- })
- return this;
- };
- })(jQuery);
- //example usage
- // $('.datepicker').typed({callback : change_form});
Add Comment
Please, Sign In to add comment