Ruby on Rails latest stable (v5.2.3) - 0 notes - Class: ActionView::Helpers::PrototypeHelper::JavaScriptGenerator::GeneratorMethods

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v3.0.9) is shown here.

insert_html(position, id, *options_for_render) public

Inserts HTML at the specified position relative to the DOM element identified by the given id.

position may be one of:


HTML is inserted inside the element, before the element’s existing content.


HTML is inserted inside the element, after the element’s existing content.


HTML is inserted immediately preceding the element.


HTML is inserted immediately following the element.

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:

# Insert the rendered 'navigation' partial just before the DOM
# element with ID 'content'.
# Generates: Element.insert("content", { before: "-- Contents of 'navigation' partial --" });
page.insert_html :before, 'content', :partial => 'navigation'

# Add a list item to the bottom of the <ul> with ID 'list'.
# Generates: Element.insert("list", { bottom: "<li>Last item</li>" });
page.insert_html :bottom, 'list', '<li>Last item</li>'
Show source
Register or log in to add new notes.