Skip to content

Instantly share code, notes, and snippets.

@jaydeepakbari
Created August 12, 2018 04:53
Show Gist options
  • Save jaydeepakbari/6b63c4664a892f9c08eb864ab5c53116 to your computer and use it in GitHub Desktop.
Save jaydeepakbari/6b63c4664a892f9c08eb864ab5c53116 to your computer and use it in GitHub Desktop.
Button loading jquery Plugin
(function ($) {
$.fn.button = function (action) {
var self = $(this);
if (action == 'loading') {
if ($(self).attr("disabled") == "disabled") {
e.preventDefault();
}
$(self).attr("disabled", "disabled");
$(self).attr('data-btn-text', $(self).html());
$(self).html('<i class="fa fa-spinner fa-spin"></i>' + $(self).text());
}
if (action == 'reset') {
$(self).html($(self).attr('data-btn-text'));
$(self).removeAttr("disabled");
}
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment