Last active
August 29, 2015 14:02
-
-
Save nim23/0339f078c835bcd39ff0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<!-- ko if:inProgress --> | |
<img data-bind="attr: { src: progressIcon }" /> | |
<!-- /ko --> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.