Created
March 7, 2014 19:58
-
-
Save JefClaes/9418765 to your computer and use it in GitHub Desktop.
A generic self-contained self-refreshing knockout.js model for binding to a dashboard widget.
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
| var ajaxWidgetModel = function (options) { | |
| var self = this; | |
| self.data = ko.observable(); | |
| self.tick = function () { | |
| $.get(options.url, function (data) { | |
| self.data(ko.mapping.fromJS(data)); | |
| }); | |
| }; | |
| self.tick(); | |
| setInterval(self.tick, options.interval); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment