如何以ELM形式使用Html.form? [英] How to use Html.form in ELM form?

查看:65
本文介绍了如何以ELM形式使用Html.form?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个HTML表单,该表单实际上使用ELM中的[form]标签。在线示例都没有这样做-他们只是将[input]标记放在[div]而不是[form]

I want to make an HTML form that actually uses the [form] tag in ELM. None of the example online do this -- they simply put the [input] tags in a [div] instead of a [form]

当我尝试切换Elm应用时到一个[form],我的[input type = sumbit]标签似乎没有回调给Elm。提交者尝试离开页面并添加?

When I try switching my Elm app to a [form], my [input type=sumbit] tags don't seem to call back to Elm. The submit tries to leave the page and add a "?" to my url.

有关如何执行此操作的任何提示?

Any hints on how to do this?

为什么:我想成为一个使用[form],因此我可以在某些[input]字段上使用 required属性。这只是我验证的一部分,但我喜欢必需标记显示的UI。

WHY: I want to be a using [form], so I can use the "required" attribute on some [input] fields. This is just one part of my validation, but I like the UI that "required" tag presents.

推荐答案

您应使用< Html.form 中的code> onSubmit 。

You should use onSubmit in Html.form.

以下是示例。

Html.form [ onSubmit Submit ]
  [ input
    [ type' "submit"
    , value "click here to submit"
    ]
    []
  ]

这篇关于如何以ELM形式使用Html.form?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆