method
insert_html

v3.0.9 -
Show latest stable
-
0 notes -
Class: ActionView::Helpers::PrototypeHelper::JavaScriptGenerator::GeneratorMethods
- 1.0.0
- 1.1.6 (0)
- 1.2.6 (0)
- 2.0.3 (6)
- 2.1.0 (0)
- 2.2.1 (0)
- 2.3.8 (0)
- 3.0.0 (0)
- 3.0.9 (-2)
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- What's this?
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:
:top |
HTML is inserted inside the element, before the element’s existing content. |
:bottom |
HTML is inserted inside the element, after the element’s existing content. |
:before |
HTML is inserted immediately preceding the element. |
:after |
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>'