on develop help sign in
Add elDynHtml' and unsafePlaceElement
a8dbf29Ryan Trinkle
src/Reflex/Dom/Widget/Basic.hs+13−1
@@ -352,6 +352,13 @@ elClass tag c child = elAttr tag ("class" =: c) child
352
352
353list dm mkChild = listWithKey dm (\_ dv -> mkChild dv)
353list dm mkChild = listWithKey dm (\_ dv -> mkChild dv)
354
354
355+elDynHtml' :: MonadWidget t m => String -> Dynamic t String -> m (El t)
356+elDynHtml' elementTag html = do
357+ e <- buildEmptyElement elementTag (Map.empty :: Map String String)
358+ schedulePostBuild $ liftIO . htmlElementSetInnerHTML e =<< sample (current html)
359+ addVoidAction $ fmap (liftIO . htmlElementSetInnerHTML e) $ updated html
360+ wrapElement e
361+
355{-
362{-
356
363
357--TODO: Update dynamically
364--TODO: Update dynamically
@@ -434,4 +441,9 @@ tabDisplay ulClass activeClass tabItems = do
434 a <- link x
441 a <- link x
435 return $ fmap (const k) (_link_clicked a)
442 return $ fmap (const k) (_link_clicked a)
436
443
437−
444+-- | Place an element into the DOM and wrap it with Reflex event handlers. Note: undefined behavior may result if the element is placed multiple times, removed from the DOM after being placed, or in other situations. Don't use this unless you understand the internals of MonadWidget.
445+unsafePlaceElement :: MonadWidget t m => HTMLElement -> m (El t)
446+unsafePlaceElement e = do
447+ p <- askParent
448+ liftIO $ nodeAppendChild p $ Just e
449+ wrapElement e