Forum: Ruby on Rails Problem with ajax and textareas on firefox but works on IE

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Daniel Teng (Guest)
on 2006-03-10 21:25
(Received via mailing list)
Hi folks,

I've been trying to figure this one out for a few hours now and can't
seem to understand what I might be doing wrong here.  Basically, I have
a textarea which has a little icon next to it which will fire off a
reset of the original comment if pressed.  It works under IE so that
when the user types some garbase in to the textarea, and clicks the
icon, the contents of the textarea resets; however, under firefox, i can
see the ajax call hitting the server (the console shows it), but the
text area doesn't refresh.

I have the following textarea in my _form.rhtml (and have the <%=
javascript_include_tag "prototype" %> in the layout rhtml file.
    <td>
        <%= text_area 'reviewcomment', 'safety', 'cols' => 45, 'rows' =>
5 %>
    </td>
    <td>
        <%=
link_to_remote(image_tag("/images/UI/buttons/open_review.gif"),:update
=> 'reviewcomment_safety',:url => {:action => 'resetComment', :factor =>
'Safety', :rating => @reviewrating.safety}) %>
    </td>

In my controller, the code looks like
  def resetComment
    @factor = params[:factor]
    @rating = params[:rating]
    @rt = Ratingtemplate.find(:first, :conditions=> ["factor = ? AND
rating = ?", @factor, @rating])
    @comment = @rt.defaultcomment
    render(:layout => false)
  end

And finally, I have a resetComment.rhtml
<%= @comment %>


Any help on this would be greatly appreciated!
Daniel
Lori O. (Guest)
on 2006-03-10 23:11
Daniel Teng wrote:
>
> And finally, I have a resetComment.rhtml
> <%= @comment %>
>
>
> Any help on this would be greatly appreciated!
> Daniel

Doesn't resetComment.rhtml need to be a partial?  eg:
_resetComment.rhtml
Daniel Teng (Guest)
on 2006-03-10 23:29
(Received via mailing list)
I tried changing that to _resetComment.rhtml, but with no effect.  I
also assumed that in the controller, I had to do the follow?

render :=>partial "resetComment"

In both cases, it did not seem to make a difference under firefox.
Arghhhhh....
Tony J. (Guest)
on 2006-03-11 04:40
Can you try <%=h @comment %> instead?
Firefox is more strict sometimes on returned innerHTML, better escape it
first.

Daniel Teng wrote:
> Hi folks,
>
> I've been trying to figure this one out for a few hours now and can't
> seem to understand what I might be doing wrong here.  Basically, I have
> a textarea which has a little icon next to it which will fire off a
> reset of the original comment if pressed.  It works under IE so that
> when the user types some garbase in to the textarea, and clicks the
> icon, the contents of the textarea resets; however, under firefox, i can
> see the ajax call hitting the server (the console shows it), but the
> text area doesn't refresh.
Daniel Teng (Guest)
on 2006-03-13 07:24
(Received via mailing list)
Thanks Tony,

I tried that and it seems to at least work the first time around
now(didn't work at all before).  I wonder if I need to rename the file
to _resetComment.rhtml?  It's being included in the _form.rhtml called
by the edit action.

Daniel
This topic is locked and can not be replied to.