0

I'm building an Elm application and am trying to add navigation as per the manual.

I've added the required handling of LinkClicked and UrlChanged and they work fine for href, but they don't work for buttons that lead to different pages.

For example, in my search page:

    ...
    , Input.button [ centerX ] -- This doesn't trigger a navigation message
        { onPress = Just StartSearch
        , label = text "Search"
        }
    , Element.link []  -- This triggers a navigation message
        { label = text "Search"
        , url = "/search"
        }
    ...

How do I apply navigation changes when buttons are clicked?

noamt
  • 7,397
  • 2
  • 37
  • 59
  • Why not put whatever navigation change you want to happen in the 'StartSearch' branch of the case in your 'update' function? – 8n8 Jul 30 '19 at 12:41
  • @5ndG according to the manual, the linkclicked / urlchanged messages result in a command. Am I able to perform both that command and the command required for starting my search as a result of that single message? – noamt Jul 30 '19 at 12:58
  • Yes, you can [batch](https://package.elm-lang.org/packages/elm/core/latest/Platform-Cmd#batch) commands. – 8n8 Jul 30 '19 at 13:06

0 Answers0