Commit b9463e8b authored by Stephane Glondu's avatar Stephane Glondu

Question editor: allow insertion of answer anywhere

parent c79d3ed9
......@@ -75,7 +75,7 @@ let extractTemplate () =
(* Injecting the OCaml structure into the DOM *)
let createAnswer a =
let rec createAnswer a =
let container = Dom_html.createDiv document in
let t = document##createTextNode (Js.string "Answer: ") in
let u = Dom_html.createInput document in
......@@ -94,6 +94,17 @@ let createAnswer a =
btn##onclick <- handler f;
Dom.appendChild btn btn_text;
Dom.appendChild container btn;
let insert_text = document##createTextNode (Js.string "Insert") in
let insert_btn = Dom_html.createButton document in
let f _ =
let x = createAnswer "" in
container##parentNode >>= fun p ->
Dom.insertBefore p x (Js.some container);
return ()
in
insert_btn##onclick <- handler f;
Dom.appendChild insert_btn insert_text;
Dom.appendChild container insert_btn;
container
let createQuestion q =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment