Skip to content

Commit

Permalink
fix to bindatom, adding checkbox support
Browse files Browse the repository at this point in the history
  • Loading branch information
mjtodd committed Apr 24, 2012
1 parent ec161dd commit a6fa4fb
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src-cljs/cljsbinding.cljs
Expand Up @@ -74,13 +74,31 @@
(doseq [data (.split (attr elem "bind") ";")] (bind-elem elem (.split data ":") ctx))
)

(defn bindatom [elem]
(defn bind-input-atom [elem]
(run-bind-fn #(.call (aget elem "val") elem (deref (js/eval (attr elem "bindatom")))))

(.change elem #(
(reset! (js/eval (attr elem "bindatom")) (.val elem))
:false
))
(.change elem
(fn []
(reset! (js/eval (attr elem "bindatom")) (.val elem))
false)
)
)

(defn bind-checkbox-atom [elem]
(run-bind-fn #(checked elem (deref (js/eval (attr elem "bindatom")))))

(.change elem
(fn []
(reset! (js/eval (attr elem "bindatom")) (.is elem ":checked"))
false)
)
)

(defn bindatom [elem]
(if (= "checkbox" (attr elem "type"))
(bind-checkbox-atom elem)
(bind-input-atom elem)
)
)

(defn bindall [parent ctx]
Expand Down

0 comments on commit a6fa4fb

Please sign in to comment.