我已经了解了获取单个选择的选定索引所需的内容,但我有兴趣从多选中获取所有选定的选项。我一直无法弄清楚如何做到这一点。
我尝试了以下操作,但我怀疑 Json 解码器失败。但我不能 100% 确定这一点,因为解码发生在虚拟 dom 代码中,并且那里的任何错误都会被丢弃。
type Msg
= SetMultipleInts (List Int)
-- I'm not seeing the SetMultipleInts message when I click on the multiselect
view model =
div []
[ select (onSelect SetMultipleInts) (List.map myOption [1..4]) ]
myOption : Int -> Html Msg
myOption id =
option [ value (toString id) ] [ text <| "Option " ++ (toString id) ]
-- I'm not seeing anything happen in the onchange
onMultiSelect : (List Int -> …Run Code Online (Sandbox Code Playgroud)