Skip to content

Instantly share code, notes, and snippets.

@David-Melo
Created April 23, 2014 15:40
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 David-Melo/11220433 to your computer and use it in GitHub Desktop.
Save David-Melo/11220433 to your computer and use it in GitHub Desktop.
Class Def
var self = this;
if(!page){
var page = {
id: null,
site: null,
type: null,
name: null,
url: null,
createdAt: moment().format(),
updatedAt: moment().format()
}
}
self.data = {
id: ko.observable(),
site: ko.observable(),
type: ko.observable(),
name: ko.observable(),
url: ko.observable(),
createdAt: ko.observable(),
updatedAt: ko.observable()
};
self.init = function(page){
self.data.id(page.id);
self.data.site(page.site);
self.data.type(page.type);
self.data.name(page.name);
self.data.url(page.url);
self.data.createdAt(page.createdAt);
self.data.updatedAt(page.updatedAt);
};
self.utils = {
validation: ko.validation.group(self.data),
revert: function(){
self.dirtyFlag.revert();
self.dirtyFlag.reset();
}
}
self.init(page);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment