react.rb icon indicating copy to clipboard operation
react.rb copied to clipboard

additional jquery helper methods

Open catmando opened this issue 9 years ago • 1 comments

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.

catmando avatar Jan 21 '16 23:01 catmando

This issue was moved to reactrb/reactrb#121

sollycatprint avatar Jun 13 '16 13:06 sollycatprint