Skip to content

Instantly share code, notes, and snippets.

@thbar
Created May 28, 2012 15:17
Show Gist options
  • Save thbar/2819684 to your computer and use it in GitHub Desktop.
Save thbar/2819684 to your computer and use it in GitHub Desktop.
Global "spinner" with jQuery, KnockOut.js and CoffeeScript

I wanted a quick "data is synchronizing" global spinner for WiseCash - here is what I came up with.

<body>
<!-- stuff -->
<span class="ajaxLoader" data-bind="visible: ajaxLoader">Syncing data...</span>
</body>
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))
@joshuapinter
Copy link

Using a similar thing for something else and this helped with how it's applied in CoffeeScript specifically, so thanks for posting.

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