Daniel Teng
2006-Mar-10 19:22 UTC
[Rails] Problem with ajax and textareas on firefox but works on IE
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 Olson
2006-Mar-10 21:11 UTC
[Rails] Re: Problem with ajax and textareas on firefox but works on
Daniel Teng wrote:> > And finally, I have a resetComment.rhtml > <%= @comment %> > > > Any help on this would be greatly appreciated! > DanielDoesn''t resetComment.rhtml need to be a partial? eg: _resetComment.rhtml -- Posted via http://www.ruby-forum.com/.
Daniel Teng
2006-Mar-10 21:26 UTC
[Rails] Re: Problem with ajax and textareas on firefox but works on
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.... Lori Olson wrote:> 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 > >
Tony Jin
2006-Mar-11 02:40 UTC
[Rails] Re: Problem with ajax and textareas on firefox but works on
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.-- Posted via http://www.ruby-forum.com/.
Daniel Teng
2006-Mar-13 05:23 UTC
[Rails] Re: Problem with ajax and textareas on firefox but works on
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 Tony Jin wrote:> 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. >> > >
Seemingly Similar Threads
- Quick question about @params
- disable ''tab'' key wish for incremental autocomplete of textareas
- Fwd: Re: disable ''tab'' key wish for incremental autocomplete of textareas
- Where are the session objects stored in the filesystem on the server?
- merging two lists but get indexes