Created
December 5, 2012 09:30
-
-
Save jsmarkus/4214254 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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