Skip to content

Commit

Permalink
added support for using a map to bind multiple fields to atom. fixes f…
Browse files Browse the repository at this point in the history
  • Loading branch information
mjtodd committed Jun 19, 2012
1 parent b27d236 commit 240f099
Show file tree
Hide file tree
Showing 10 changed files with 478 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -30,6 +30,8 @@ As well as binding UI elements to functions that are dependent on atoms, atoms c


For checkbox inputs, special handling is applied, so that you can bind an atom with a boolean value in exactly the same way. For checkbox inputs, special handling is applied, so that you can bind an atom with a boolean value in exactly the same way.


If the atom is a map, then multiple input elements can be bound to the atom. In this case, the id of the input element is used as the key to lookup the particular item in the map e.g. `<input bindatom="sample.myatom" type="text" id="mykey"` will bind the input to the item in the map with key `:mykey`. Again, this will be a two way binding, so whenever the input fires the change event, the atom will be updated with a new map.

### Sequences and loops ### Sequences and loops


In addition to binding form input elements to atoms, you can also bind regions of html to an atom that is a sequence. This will clone the region of html for each item in the sequence. The region of html can also contain bindings. In this case, the binding functions will be called with a single parameter, which is the item from the sequence. This is best demonstrated with an example: In addition to binding form input elements to atoms, you can also bind regions of html to an atom that is a sequence. This will clone the region of html for each item in the sequence. The region of html can also contain bindings. In this case, the binding functions will be called with a single parameter, which is the item from the sequence. This is best demonstrated with an example:
Expand Down
10 changes: 10 additions & 0 deletions examples/maptest/.gitignore
@@ -0,0 +1,10 @@
/target
/lib
/classes
/checkouts
pom.xml
*.jar
*.class
.lein-deps-sum
.lein-failures
.lein-plugins
13 changes: 13 additions & 0 deletions examples/maptest/README.md
@@ -0,0 +1,13 @@
# binding-maptest

A simple example for the cljs-binding library showing how a single atom that is a map can be used to bind to multiple input fields

## Usage

Run `lein cljsbuild once` to compile the ClojureScript, then simply open index.html

## License

Copyright © 2012 Fluent Software Solutions Ltd

Distributed under the Eclipse Public License, the same as Clojure.

0 comments on commit 240f099

Please sign in to comment.