replace(id, *options_for_render) Replaces the "outer HTML" (i.e., the entire element, not just its contents) of the DOM element with the given id. options_for_render may be either a string of HTML to insert, or a hash of options to be passed to ActionView::Base#render. For example: # Replace the DOM element having ID 'person-45' with the # 'person' partial for the appropriate object. page.replace 'person-45', :partial => 'person', :object => @person This allows the same partial that is used for the insert_html to be also used for the input to replace without resorting to the use of wrapper elements. Examples: <div id="people"> <%= render :partial => 'person', :collection => @people %> </div> # Insert a new person # # Generates: new Insertion.Bottom({object: "Matz", partial: "person"}, ""); page.insert_html :bottom, :partial => 'person', :object => @person # Replace an existing person # Generates: Element.replace("person_45", "-- Contents of partial --"); page.replace 'person_45', :partial => 'person', :object => @person Source: show | on GitHub replace_html(id, *options_for_render) Replaces the inner HTML of the DOM element with the given id. options_for_render may be either a string of HTML to insert, or a hash of options to be passed to ActionView::Base#render. For example: # Replace the HTML of the DOM element having ID 'person-45' with the # 'person' partial for the appropriate object. # Generates: Element.update("person-45", "-- Contents of 'person' partial --"); page.replace_html 'person-45', :partial => 'person', :object => @person Source: show | on GitHub |