I want to add a child to an HTML element. In this case, the element is
“tbody” and the HTML is a row.
The insert_html method requires me to specify :after, :before, etc,
which in this case is not appropriate. The insert method in the new
version of prototype (1.6) allows you to specify just 2 parameters:
the id of the element and the content to add to it as a child.
Optionally, one can specify the position. The Insert.After,
Insert.Before, etc., are now deprecated (and this is what Rails is
using internally).
What I ended up doing was something like:
page.call(“myAppendChild”, id, html_content), which is calling my own
js function and passing it a template rendered into a string – not
very clean I think.
Is there a way to append a child to an element from within Rails
without resorting to my js functions?
Fred, thanks for the reply. See in my case, Element.update will not
work because if I do a replace_html on the tbody, all the other rows
will disappear and only the new one will remain. I need to add one row
in addition to all other rows, whose parent is a tbody. Does it make
sense?
Fred, thanks for the reply. See in my case, Element.update will not
work because if I do a replace_html on the tbody, all the other rows
will disappear and only the new one will remain. I need to add one row
in addition to all other rows, whose parent is a tbody. Does it make
sense?
then surely insert_html :bottom is what you want ? Rails has/will be
updated on edge to use the new Element.insert($('foo), {bottom:
stuff}) rather than Insertion.xxx
Fred
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.