Skip to content

Instantly share code, notes, and snippets.

@yreynhout
Created August 4, 2012 11:36
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 yreynhout/3256867 to your computer and use it in GitHub Desktop.
Save yreynhout/3256867 to your computer and use it in GitHub Desktop.
Viewmodels - Sample 3
var ThingInputViewModel=function() {
if(!this instanceof ThingInputViewModel) {
return new ThingInputViewModel();
}
var self=this;
self.Name=new TextInput({
rules: {
required: true,
minLength: ns.MetaData.Name.MinimumLength,
maxLength: ns.MetaData.Name.MaximumLength
},
messages: {
required: ns.Resources.FieldIsRequired,
minLength: ns.Resources.MustHaveMinimumLength,
maxLength: ns.Resources.MustNotExceedMaximumLength
}
});
self.Save=new Trigger();
self.Cancel=new Trigger();
self.Durations=new DurationsViewModel();
self.Periods=new PeriodsViewModel();
// Behavior example: composite enabling/disabling
self.enable = function() {
self.Name.enable();
self.Durations.enable();
self.Periods.enable();
self.Save.enable();
self.Cancel.enable();
};
self.disable = function() {
self.Name.disable();
self.Durations.disable();
self.Periods.disable();
self.Save.disable();
self.Cancel.disable();
};
return self;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment