Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClojureScript - get checkbox element value

I have the following code (from om.next) creating a checkbox input. The creation works fine, but I don't know how to get the event value, as I don't see the value somewhere in the logs when I click on it (there is a lot of data though) :

(dom/input #js {:type    "checkbox"
                :onClick (fn [e] (js/console.log e)) ;; how do I get the current true/false value from `e` ?
               })

I get in the logs (abbreviated) :

SyntheticMouseEvent {dispatchConfig: Object, dispatchMarker: ".0.0.1.$[cardpath]=1[om_tutorial=1B_UI_Exercises]=1[exercise-3].0.$-184795562.1.0", nativeEvent: MouseEvent, target: input, currentTarget: input…}

Note : the code is from there.

like image 570
nha Avatar asked Jan 28 '16 15:01

nha


1 Answers

(.- target e) returns you the element, generally you want the .-value from an element, but for a checkbox you want .-checked instead... so something like

(.. e -target -checked)
like image 91
Timothy Pratley Avatar answered Sep 28 '22 05:09

Timothy Pratley