I wanted a quick "data is synchronizing" global spinner for WiseCash - here is what I came up with.
Created
May 28, 2012 15:17
-
-
Save thbar/2819684 to your computer and use it in GitHub Desktop.
Global "spinner" with jQuery, KnockOut.js and CoffeeScript
This file contains 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
<body> | |
<!-- stuff --> | |
<span class="ajaxLoader" data-bind="visible: ajaxLoader">Syncing data...</span> | |
</body> |
This file contains 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
class @MyModel | |
constructor: -> | |
@ajaxLoader = ko.observable(false) | |
jQuery => | |
model = new MyModel() | |
ko.applyBindings(model) | |
jQuery(document).ajaxStart(=> model.ajaxLoader(true)) | |
jQuery(document).ajaxStop(=> model.ajaxLoader(false)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using a similar thing for something else and this helped with how it's applied in CoffeeScript specifically, so thanks for posting.