Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix to bindatom, adding checkbox support

  • Loading branch information...
commit a6fa4fba9dda391913e34f72795ec12745ed9d0b 1 parent ec161dd
mjtodd mjtodd authored
Showing with 23 additions and 5 deletions.
  1. +23 −5 src-cljs/cljsbinding.cljs
28 src-cljs/cljsbinding.cljs
View
@@ -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]
Please sign in to comment.
Something went wrong with that request. Please try again.