Skip to content

Instantly share code, notes, and snippets.

@motowilliams
Created July 17, 2012 16:35
Show Gist options
  • Save motowilliams/3130492 to your computer and use it in GitHub Desktop.
Save motowilliams/3130492 to your computer and use it in GitHub Desktop.
Knockout ViewModel
$(function() {
var viewModel = function() {
var self = this;
self.address = ko.observable("Portland");
self.list = ko.observableArray();
self.hasData = function(){return self.list().length > 0;};
self.search = function() {
self.list.push({ addr: "Item01" , index: 1 });
self.list.push({ addr: "Item02" , index: 2 });
self.list.push({ addr: "Item03" , index: 3 });
};
};
var vm = new viewModel();
ko.applyBindings(vm);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment