Created
July 13, 2010 03:40
-
-
Save banyan/473424 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* 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