Skip to content

Instantly share code, notes, and snippets.

@banyan
Created July 13, 2010 03:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save banyan/473424 to your computer and use it in GitHub Desktop.
Save banyan/473424 to your computer and use it in GitHub Desktop.
/**
* jquery.disableDoubleSubmit
*
* @description When submit, the element will be disabled and show loading image.
* @author http://d.hatena.ne.jp/bannyan/
* @license The MIT License
* @version 1.0
* @link http://gist.github.com/473424
*
* @usage
*
* $('#element').disableDoubleSubmit();
* $('#element').disableDoubleSubmit({img_src: "/path/to/another_image", margin: "10 0"});
*/
(function() {
jQuery.fn.disableDoubleSubmit = function(config) {
config = jQuery.extend({
img_src: "/image/loading.gif"
}, config);
// Preload image.
(new Image).src = config.img_src;
var target = this;
target.after('<img src="' + config.img_src + '" />')
target.hide();
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment