hyper-react
hyper-react copied to clipboard
additional jquery helper methods
From @catmando on January 21, 2016 23:41
Here are a couple of handy methods we have started to use in our code, that I would like to see appear in 0.8 or 0.9:
React::Element#append_to(dom_element) # append this element to an existing DOM element i.e.
div { "some div stuff" }.append_to(Element['.put-a-div-here'])
Element#append(ele="<div></div>", &block)
# append an element (default an empty div) to this dom element, and
# render the block into the appended element (if the block exists) i.e.
Element['.add-something'].append do
div { button { "click me" } }
end
# The first parameter (ele) is maintained so its compatible with the existing jQuery
Element#replace_with(ele="<div></div>", &block)
# like append but the existing element is replaced.
Copied from original issue: zetachang/react.rb#121
@zetachang - again a few of these might have gotten done already...