问题
I have this frameset division:
<frameset cols="*,200">
<frame name="main" src="/main.html">
<frame name="sidebar" src="/sidebar">
</frameset>
And this is my elm
logic is inside main.html
:
import Html exposing (..)
import Html.Attributes exposing (..)
view : Model -> Html Msg
view model =
Html.form [method "POST", action "/sidebar", target "sidebar" ]
[ input [ type_ "text" ,placeholder "user"] [],
input [ type_ "password", placeholder "password"] [],
input [ type_ "submit" ,value "Submit"] []
]
I want to invoke the form submission from my code.
How can I trigger the submission of the form from elm
?
EDIT:
This is what I came up with, pretty ugly:
submit2frame frm = attribute "onclick" ("javascript:this.form.target=" ++ frm ++ ";this.form.action=\"/" ++ frm ++ "\";this.form.submit();")
来源:https://stackoverflow.com/questions/46522003/submitting-a-form-from-elm-code