on develop help sign in
Add elDynHtml' and unsafePlaceElement
commita8dbf291cfa02fae3ca759dd76487dea860a6f18 authorRyan Trinkle <ryan.trinkle@gmail.com> dateSun 1 Mar 2015, 18:48 (12 years ago) parentc1e8e10
1 file changed+13−1
src/Reflex/Dom/Widget/Basic.hs+13−1
src/Reflex/Dom/Widget/Basic.hs+13−1
@@ -352,6 +352,13 @@ elClass tag c child = elAttr tag ("class" =: c) child
352352
353353list dm mkChild = listWithKey dm (\_ dv -> mkChild dv)
354354
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+
355362{-
356363
357364--TODO: Update dynamically
@@ -434,4 +441,9 @@ tabDisplay ulClass activeClass tabItems = do
434441 a <- link x
435442 return $ fmap (const k) (_link_clicked a)
436443
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