Closed kaizhang closed 7 years ago
Try to instead use the event from getPostBuild
:
pb <- getPostBuild
performEvent_ $ DOM.liftJSM . configSidebar (_element_raw e1) .
(const config) <$> pb
getPostBuild
does return a usable event. But the event seems to occur before the "pusher" is loaded, because I still got the same error from semui: Sidebar: – "Had to add pusher element. For optimal performance make sure body content is inside a pusher element"
Where is the documentation of the getPostBuild
function and why is the Load
event never happened?
domEvent Load
does not work because onload
only works for following tags: <body>, <frame>, <iframe>, <img>, <input type="image">, <link>, <script>, <style>
.
I don't know why pb <- getPostBuild
does not work. But I found pb <- delay 0 =<< getPostbuild
works. Can anyone explain this?
@kaizhang That's probably because the event from getPostBuild
fires immediately after the widget is built - but usually before it's placed in the document. When you add the delay 0
, you will generally delay until after the element has been placed in the document. If it's possible to write your code so that it works regardless of whether the widget is in the document or not, that's the most robust approach. Otherwise, there is a PR being worked on that will give you a nice way of doing things when the widget is mounted.
@ryantrinkle That makes sense. To do what you suggested, I probably need to rewrite the js part of semantic UI in Haskell. I do not want to do that for now. I hope the PR can be merged soon. Right now I will just use a safe value for delay
.
This may not directly relate with this package. I am implementing the "sidebar" widget from Semantic UI. I'm new to both semui and reflex. And I had hard time to get the sidebar initialization process worked. I want to call
$(.sidebar).sidebar({ dimPage: false})
after the sidebar is loaded (I found that it will lead to an error if this function is called before the elements are loaded). So I used the "Load" event. However, for some reasons the event never fired. Other than not being able to change the settings, my sidebar implementation works as expected. Here is the codes. Any suggestions? Thanks!