Appending to a textarea with RJS

Ok, this is driving me nuts. I’m trying to RJS some text into a
text_area which may or may not have been written in by the user. if I
page.insert_html :before, :after, :top, or :bottom, it either sticks
the contents above or below the text box (but never in). If I do:

page[:textboxid].value = “blah”

it overwrites the contents of the textbox but doesn’t APPEND to it.
I’ve tried doing something to the effect of

page[:textboxid].value = “blah” + page[:textboxid].value
or
page[:textboxid].value = “blah” + $#{‘textboxid’}.value

and several variants. But I keep getting errors. Or… nothing.
Someone please help me before I put my fist through my screen.

Thats a good question. I can’t get it to work with RJS, but this simple
prototype based javascript works fine. I guess you could stick it in a
function and call your function from RJS.

$(‘tarea’).value = $(‘tarea’).getValue() + " blah"

johnhutch wrote:

page[:textboxid].value = “blah” + page[:textboxid].value
or
page[:textboxid].value = “blah” + $#{‘textboxid’}.value

and several variants. But I keep getting errors. Or… nothing.
Someone please help me before I put my fist through my screen.


Sincerely,

William P.

YAYYYY IT WORKED! Here’s my RJS/javascript code:

  <%= link_to_function "Append to Text Area" do |page|
    page << "$('textarea_id').value = $('textarea_id).getValue() +

‘blah!’"
end
%>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs