Skip to content

Instantly share code, notes, and snippets.

@valerysntx
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valerysntx/c2bfe73a4783b9ebc99a to your computer and use it in GitHub Desktop.
Save valerysntx/c2bfe73a4783b9ebc99a to your computer and use it in GitHub Desktop.
define(['jquery', 'knockout', 'knockout.mapping', 'knockout.validation'],
function ($, ko) {
/** The module. */
var self = {};
/** The knockout view model. */
self.viewModel = {};
/** The knockout container. */
self.container = null;
/** Initialise the module. */
self.initialise = function (container) {
self.container = container;
// Call API end point.
$.getJSON('/API/End/Point',
function (json) {
self.viewModel = ko.mapping.fromJS(json);
extendViewModel();
var context = ko.contextFor(self.container);
if (context === undefined)
ko.applyBindings(self.viewModel, self.container);
}
);
};
/** Extend the view model. */
var extendViewModel = function () {
};
return self;
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment