Skip to content

Instantly share code, notes, and snippets.

@jsmarkus
Created December 5, 2012 09:30
Show Gist options
  • Save jsmarkus/4214254 to your computer and use it in GitHub Desktop.
Save jsmarkus/4214254 to your computer and use it in GitHub Desktop.
var form = new ko.Form({
layout : 'vertical',
title : 'Create post',
fields : [
{
name : 'title',
type : 'Text'
},
{
name : 'body',
type : 'Textarea'
},
{
name : 'tags',
type : 'TagList'
},
],
actions : [
{
name : 'cancel',
title : 'Cancel'
},
{
name : 'submit',
title : 'Submit',
bindings :
{
enable : ko.computed(function () {
return this.fieldByName('title').value() === '';
})
}
}
]
});
//--------------------------------------------------------------------
form.renderTo(document.getElementById('front_screen'));
var form = new ko.Form({
/*see example koform.js*/
});
//--------------------------------------------------------------------
form.renderTo(document.getElementById('front_screen'));
//--------------------------------------------------------------------
var model = new Backbone.Model({title:'hello', body:'world', tags:['foo', 'bar']});
var queue = new BackboneToKOFormConnector();
queue.setForm(form);
queue.setModel(model);
//now form and model are bound together.
//Any change of model is reflected in form,
//as well as any change of form is reflected in model.
//'save' action of form tries to call save() on model, etc...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment