Last active
August 14, 2023 03:00
-
-
Save dinhhuydh/c6f27c05c2f47e86d3ce1474cb1b8076 to your computer and use it in GitHub Desktop.
Add more information for Events.onInput in elm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-| Suppose that you have many inputs for list of users (first_name, last_name) | |
To handle event onInput for inputs for each elements, it needs to bind Event.onInput for | |
inputs but Event.onInput support pass one string value. To customize that it's able to | |
include more information, for example user id, we can declare the Message as below: | |
-} | |
type Msg | |
= UpdateFirstName Int String | |
-- View | |
Html.input [Events.onInput (UpdateFirstName user.id) ] [] | |
-- Reference: https://package.elm-lang.org/packages/elm/html/latest/Html-Events#onInput |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment