Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliom_content.Html.D.Raw.input submit disappears from page on refresh #632

Open
RuyBlast opened this issue Mar 27, 2020 · 0 comments
Open

Comments

@RuyBlast
Copy link

RuyBlast commented Mar 27, 2020

Hi !
I just observed a strange behavior building a client-server Eliom application, I report it in case it is a bug.
I used ocsigen-start and customized it this way:

(* inside app_name_handlers.eliom *)
let%shared wish_page =
  let open Eliom_content.Html.D in
  let wish_input = (Raw.input ~a:[a_input_type `Text]) () in
  let wish_submit = (Raw.input ~a:[a_input_type `Submit; a_value "Send"]) () in
  let wish_list = div ~a:[a_id "wish-list"] [] in
  [%client (
    let open Js_of_ocaml_lwt.Lwt_js_events in
    async (fun () -> let open Eliom_content.Html in
      clicks (To_dom.of_input ~%wish_submit)
        (fun _ _ -> let open Js_of_ocaml in
         let wish = Js.to_string (To_dom.of_input ~%wish_input)##.value in
                 let%lwt ok =
                   Eliom_client.call_ocaml_service
                     ~service:~%App_name_services.wish_service () wish
                     (* ocaml service that returns a unit *)
                 in
                 Lwt.return(ok)
              )): unit)];
   Eliom_content.Html.D.div [wish_input; wish_submit; wish_list]
  
let%shared main_service_handler myid_o () () =
  Docgenius_container.page
    ~a:[ a_class ["os-page-main"] ]
    myid_o (
    [ wish_page
    ; p [%i18n welcome_text1]
    <default ocsigen-start code> ...

App_name_services.wish_service is defined and registered as one would expect, and the app builds up fine. The page displays then as expected and:
If I write something in the input field, I can click on the submit button, and it triggers expected behavior.
But then, if I refresh the page, submit button disappears. I can however get it back clicking on the link to the main page (but the if I refresh again, the button disappears again).
I fixed it making wish_page a function that takes a unit as a parameter.
Maybe it is a normal behavior of Eliom_content.Html.D.Raw input elements due to nature of D elements ?
Have a good day !

@RuyBlast RuyBlast changed the title Eliom_content.Html.D.Raw.input submit disappear from page on refresh Eliom_content.Html.D.Raw.input submit disappears from page on refresh Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant