Skip to content

Instantly share code, notes, and snippets.

@cdl
Created October 9, 2013 18:08
Show Gist options
  • Save cdl/6905555 to your computer and use it in GitHub Desktop.
Save cdl/6905555 to your computer and use it in GitHub Desktop.
(function($) {
$.fn.shush = function(btnSelector) {
// Cache global variables
var $form = $(this);
var $button = $form.children("input[type=submit]")[0];
if (btnSelector instanceof jQuery) {
$button = $form.children(btnSelector[0]);
} else if (typeof(btnSelector) == 'string') {
$button = $.find(btnSelector)[0];
}
// validate button selector
if (!btnSelector instanceof jQuery) {
// button selector is not jQuery object
throw "Expected button selector to be type 'jQuery', got + " typeof(btnSelector);
return false;
}
}
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment