Problem with ajax and textareas on firefox but works on IE


#1

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.


<%= text_area ‘reviewcomment’, ‘safety’, ‘cols’ => 45, ‘rows’ =>
5 %>


<%=
link_to_remote(image_tag("/images/UI/buttons/open_review.gif"),:update
=> ‘reviewcomment_safety’,:url => {:action => ‘resetComment’, :factor =>
‘Safety’, :rating => @reviewrating.safety}) %>

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


#2

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


#3

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…


#4

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


#5

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.