nha
nha

Reputation: 18005

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.

Upvotes: 5

Views: 1577

Answers (1)

Timothy Pratley
Timothy Pratley

Reputation: 10662

(.- 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)

Upvotes: 7

Related Questions