Skip to content

Instantly share code, notes, and snippets.

@nim23
Last active August 29, 2015 14:02
Show Gist options
  • Save nim23/0339f078c835bcd39ff0 to your computer and use it in GitHub Desktop.
Save nim23/0339f078c835bcd39ff0 to your computer and use it in GitHub Desktop.
<div>
<!-- ko if:inProgress -->
<img data-bind="attr: { src: progressIcon }" />
<!-- /ko -->
</div>
define(function() {
var progressIcon = mss.rootUrl + "Content/images/busy.gif",
inProgress = ko.observable(false);
$(document).ajaxSend(function () {
inProgress(true);
}).ajaxError(function() {
inProgress(false);
}).ajaxStop(function() {
inProgress(false);
});
return {
progressIcon: progressIcon,
inProgress: inProgress
};
});
@nim23
Copy link
Author

nim23 commented Jun 24, 2014

I have found the visible binding for knockout a bit unreliable in the past, the above code removes the progress 'GIF' from the DOM completely if inProgress is set to false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment