Created
June 25, 2012 10:56
-
-
Save kinopyo/2987947 to your computer and use it in GitHub Desktop.
jQuery: disables button and swaps text to loading text.
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
// disables button and swaps text to loading text | |
$.fn.setLoadingState = function (loadingText) { | |
if (!loadingText) { | |
loadingText = 'Loading...' | |
} | |
$(this).prop('disabled', true).val(loadingText); | |
// allow jQuery chaining | |
return this; | |
}; | |
// Usage | |
$('#some_button').setLoadingState(); | |
$('#some_button').setLoadingState('Please wait...'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment