Skip to content

Instantly share code, notes, and snippets.

@developerdizzle
Last active December 18, 2015 10:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save developerdizzle/5767877 to your computer and use it in GitHub Desktop.
Save developerdizzle/5767877 to your computer and use it in GitHub Desktop.
jQuery/UpdatePanel busy/loading cursor
// html.ajax-loading { cursor: wait; }
define(['jquery'], function ($) {
$(function () {
var $html = $('html');
var $document = $(document);
var cssClass = 'ajax-loading';
var requests = 0;
function setBusy() {
if (++requests == 1) {
$html.addClass(cssClass);
}
}
function setReady() {
if (--requests == 0) {
$html.removeClass(cssClass);
}
}
//jQuery ajax hooks
$document.ajaxStart(setBusy).ajaxStop(setReady);
//ASP.Net ajax hooks
if (Sys) {
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (prm) {
prm.add_initializeRequest(setBusy);
prm.add_endRequest(setReady);
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment