1

I have an application where I'm selecting some statuses. Initially, I had a code like this

div
    [ classList
    [ onClick (SelectStatus (Just status)) ]

But at some moment, I need to stop event propagation. I found that there is an onWithOptions function but I don't know how to use it. Especially what's the Decoder parameter for. I rewrite it to this form but I'm still getting some errors.

div
    [ onWithOptions "click" { stopPropagation = True, preventDefault = False } keyCode (SelectStatus (Just status))

This is the error message

Function `onWithOptions` is expecting 3 arguments, but was given 4.

Maybe you forgot some parentheses? Or a comma?at line 171 col 11
ondrej
  • 967
  • 7
  • 26

1 Answers1

2

Your link is pointing to an obsolete package as of Elm 0.17. Here is the correct version: http://package.elm-lang.org/packages/elm-lang/html/1.1.0/Html-Events#onWithOptions

I think this would give you the functionality you're after:

onWithOptions "click" { stopPropagation = True, preventDefault = False } (Json.succeed (SelectStatus (Just status)))
Chad Gilbert
  • 36,115
  • 4
  • 89
  • 97
  • Damn Google, I took the first link it gave me. It looked so trustworthy. Thank you very much. – ondrej Jul 02 '16 at 04:39