Ultimately, I found this pretty easy:
First enter the item body:
getBody = do
root <- askDocument
Just nodelist <- getElementsByTagName root ("body" :: String)
Just body <- nodelist `item` 0
return body
Then, if trigger- this Event, which causes the opening of the dialogue, and visible- this Dynamic t Bool, which contains the current state, we can create a background and transfer it to the end of the body:
backdropAttr <- forDyn visible (\vis -> if vis then ("class" =: "modal-backdrop fade in")
else ("style" =: "display:none"))
(backdrop, _) <- elDynAttr' "div" backdropAttr blank
body <- getBody
let moveBackdrop = (const $ (appendChild body (Just $ _el_element backdrop))) `fmap` trigger
performEvent_ $ void `fmap` moveBackdrop
ondra source
share