Skip to content

Instantly share code, notes, and snippets.

@nquinlan
Created December 15, 2013 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nquinlan/5f73a310830d56d0c532 to your computer and use it in GitHub Desktop.
Save nquinlan/5f73a310830d56d0c532 to your computer and use it in GitHub Desktop.
[namespaced](http://api.jquery.com/on/#event-names) events for the sendgrid-subscription widget, to prevent a race condition.
$(".sendgrid-subscription-widget").on("submit.loader", function () {
$(this).addClass("loading")
.append("<img src=\"my/super/cool/loading.gif\" alt=\"Loading...\">");
$(this).find("input[type=submit").attr("disabled", "disabled");
$(".sendgrid-subscription-widget").on("success.loader.response error.loader.response", function () {
$(this).removeClass("loading")
$(this).find("img").remove();
$(this).find("input[type=submit").removeAttr("disabled");
$(this).off(".loader.response");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment