Anyone know if there's a way to programmatically set focus on an Element.Input.text
element using stylish-elephants (or style-element v5)?
Asked
Active
Viewed 358 times
1 Answers
3
It requires "elm-lang/dom": "1.1.1 <= v < 2.0.0" in elm-package.json
import Dom exposing (focus)
update msg model =
case msg of
FocusOn id ->
{ model | current_focus_id = id } ! [ Task.attempt FocusResult (focus (id)) ]
FocusResult result ->
case result of
Err (Dom.NotFound id) ->
model ! [ YourMsg]
Ok () ->
model ! []
view model = Element.layout [] <| el [onClick <| (FocusOn "id01")] (text "click here")

Jason O.
- 3,168
- 6
- 33
- 72