Skip to content

Instantly share code, notes, and snippets.

@patorash
Last active April 15, 2016 04:44
Show Gist options
  • Save patorash/1ac15f28f84cd22639f681df0e97ba2f to your computer and use it in GitHub Desktop.
Save patorash/1ac15f28f84cd22639f681df0e97ba2f to your computer and use it in GitHub Desktop.
knockout.jsでカーソルを砂時計に変えるbindingHandlerをを作った。Ajaxなど待ち時間が発生する際にお使いください。
ko.bindingHandlers.cursor_wait = {
init: function(element, valueAccessor) {
ko.computed({
read: function() {
if (ko.unwrap(valueAccessor()))
document.body.style.cursor = 'wait';
else
document.body.style.cursor = 'auto';
},
disposeWhenNodeIsRemoved: element
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment