This is brilliant, hope someone can write this all up for reference at some stage. ;) On Thu, 6 Oct 2016 at 16:53, Peter Damoc <[email protected]> wrote:
> Next challenge: how to implement Custom Elements in Elm. :) > > > On Thu, Oct 6, 2016 at 5:42 PM, 'Rupert Smith' via Elm Discuss < > [email protected]> wrote: > > On Thursday, October 6, 2016 at 12:23:53 PM UTC+1, Peter Damoc wrote: > > This works for me in both Chrome and Firefox on OS X with > the 'webcomponents-lite.js' > > Thanks for solving this. > > > After some poking around and a severe lack of documentation on the part of > Polymer, I have managed to hook into the select events like this: > > root : Model -> Html Msg > root model = > div > [ class "layout-fixed-width" ] > [ div [] > [ h4 [] [ text "Multi-select" ] > , Html.Keyed.node "div" > [ class "horizontal-section" ] > [ ( "listbox" > , paperListBox > [ attribute "multi" "" > , attribute "attr-for-selected" "value" > , on "iron-select" (selectedDecoder |> Decode.map > Selected) > ] > [ paperItem [ value "0" ] [ text "Bold" ] > , paperItem [ value "1" ] [ text "Italic" ] > , paperItem [ value "2" ] [ text "Underline" ] > , paperItem [ value "3" ] [ text "Strikethrough" ] > ] > ) > ] > ] > ] > > > selectedDecoder : Decode.Decoder (Result String Int) > selectedDecoder = > Decode.at [ "detail", "item", "value" ] Decode.string |> Decode.map > String.toInt > > That is, applying "on" to "iron-select", setting values on the items in > the list, and then using "at" from Json.Decode to drill down to where the > value is in the event. > > There's no stoppin' us now! > > -- > You received this message because you are subscribed to the Google Groups > "Elm Discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > > > > > -- > There is NO FATE, we are the creators. > blog: http://damoc.ro/ > > -- > You received this message because you are subscribed to the Google Groups > "Elm Discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
