Skip to content

Commit

Permalink
Move usage section up
Browse files Browse the repository at this point in the history
  • Loading branch information
powmedia committed Jun 1, 2012
1 parent aa0651b commit 1457353
Showing 1 changed file with 60 additions and 56 deletions.
116 changes: 60 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,6 @@ A flexible, customisable form framework for Backbone.JS applications.
- Custom HTML templates


<a name="top"/>
##Table of Contents:
- [Installation](#installation)
- [Usage](#usage)
- [Schema Definition](#schema-definition)
- [Text](#editor-text)
- [Checkboxes](#editor-checkboxes)
- [Select](#editor-select)
- [Radio](#editor-radio)
- [Object](#editor-object)
- [NestedModel](#editor-nestedmodel)
- [Date](#editor-date)
- [DateTime](#editor-datetime)
- [List](#editor-list)
- [Validation](#validation)
- [Customising templates](#customising-templates)
- [More](#more)
- [Editors without forms](#editors-without-forms)
- [Using nested fields](#nested-fields)
- [Custom editors](#custom-editors)
- [Help](#help)
- [Changelog](#changelog)



<a name="installation"/>
#Installation

Dependencies:
- [Backbone 0.9.2](http://documentcloud.github.com/backbone/)


Include backbone-forms.js and backbone-forms.css:

<link href="backbone-forms/distribution/backbone-forms.css" rel="stylesheet" type="text/css"/>
<script src="backbone-forms/distribution/backbone-forms.min.js"></script>

Optionally, you can include the extra editors, for example the List editor:

<script src="backbone-forms/distribution/editors/list.min.js"></script>

To use a custom template pack, e.g. Bootstrap, include the relevant file after backbone-forms.js:

<script src="backbone-forms/distribution/templates/bootstrap.js"></script>

If you use Backbone with node.js, you can just `require('backbone-forms');` in your index file.

Note there is also a distribution file for RequireJS / AMD.

[Back to top](#top)



<a name="usage"/>
#Usage

Define a 'schema' attribute on your Backbone models. The schema keys should match the attributes that get set on the model. `type` defaults to `Text`. When you don't need to specify any options you can use the shorthand by passing the editor name as a string.
Expand Down Expand Up @@ -100,7 +46,7 @@ To update a field after the form has been rendered, use `setValue`:
});


##Usage without models
###Usage without models

You can create a form without tying it to a model. For example, to create a form for a simple object of data:

Expand All @@ -125,9 +71,67 @@ Then instead of form.commit(), do:
var data = form.getValue(); //Returns object with new form values


##Initial data
###Initial data
If a form has a model attached to it, the initial values are taken from the model's defaults. Otherwise, you may pass default values using the `schema.data`.


#Guide

<a name="top"/>
##Table of Contents:
- [Installation](#installation)
- [Usage](#usage)
- [Schema Definition](#schema-definition)
- [Text](#editor-text)
- [Checkboxes](#editor-checkboxes)
- [Select](#editor-select)
- [Radio](#editor-radio)
- [Object](#editor-object)
- [NestedModel](#editor-nestedmodel)
- [Date](#editor-date)
- [DateTime](#editor-datetime)
- [List](#editor-list)
- [Validation](#validation)
- [Customising templates](#customising-templates)
- [More](#more)
- [Editors without forms](#editors-without-forms)
- [Using nested fields](#nested-fields)
- [Custom editors](#custom-editors)
- [Help](#help)
- [Changelog](#changelog)



<a name="installation"/>
#Installation

Dependencies:
- [Backbone 0.9.2](http://documentcloud.github.com/backbone/)


Include backbone-forms.js and backbone-forms.css:

<link href="backbone-forms/distribution/backbone-forms.css" rel="stylesheet" type="text/css"/>
<script src="backbone-forms/distribution/backbone-forms.min.js"></script>

Optionally, you can include the extra editors, for example the List editor:

<script src="backbone-forms/distribution/editors/list.min.js"></script>

To use a custom template pack, e.g. Bootstrap, include the relevant file after backbone-forms.js:

<script src="backbone-forms/distribution/templates/bootstrap.js"></script>

If you use Backbone with node.js, you can just `require('backbone-forms');` in your index file.

Note there is also a distribution file for RequireJS / AMD.

[Back to top](#top)



<a name="usage"/>

[Back to top](#top)


Expand Down

0 comments on commit 1457353

Please sign in to comment.