.rjs templates undesiered output problem


Hello everyone, I am working with rjs templates in rails, and I’m amazed
of how simple it is to generate code with ajax, however I’am having some
troubles and I can’t seem to find a way to solve’em.

Whenever I put some code in the template, let’s say:

 page.visual_effect :highlight, 'sitio37', :duration => 3

I get the desiered highlight allright, but, I also get the autogenerated
javascript code that makes it happen printed on screen, like so:

new Effect.Highlight("sitio37",{duration:3}); } catch (e) { 

alert(‘RJS error:\n\n’ + e.toString()); (that is, it highlights the
item, but it also prits the code on the left)

This very simptom, I also get with other insertions and effects, I’m
even using a partial on the template, and it’s rendering it 3 times
(being the two firs in java code and the last in proper dhtml).

I’ve been searching for a way to avoid this undesiered output (as I’ve
desided to name it), if anyone can help it would be great.

Any help is thanked in advance,


It could be an encoding problem, do you have filters in your controller
that alter the content-type headers?





Well, not really. Controlers and helpers are normal, no header or
encoding mod’s.
The closest thing I’ve found about anything resembling this, is the
I supose putting script tags would be one solution, but none of the webs
have published about .rjs templates implement something like this.

I’m thinking configration issues, but who knows.



Ok, finally, thanks to Cody at http://www.codyfauser.com

I have finally solved the problem.

It was a quite a silly issue tu be honest, but i’ll settle it here.
The thing is, before using rjs templates I had a normal remote_form_tag
with all of it’s ingredients:

<%= form_remote_tag(:update => “divid”
:url => { :action => :create },
:position => “top”,
:success => %(Element.hide(‘ajxform’)) ) %>

My problem was, that when I started using rjs templates, I didn’t
realize that the update param (:update => “divid”) was generating extra
prints on the screen.

remove the update param alltoghether, and its working like a charm.

My fault people, I didn’t see that one, sorry for taking up your time.

I put it here to help any other hwo runs into the same trouble.



The object page that is generated implicitly when we access de .rjs
template, de ActionView doc says that this page object its implicitly
wraped around an “update_page” block, it also says that update_page_tag
is exacltly like update_page only it wraps the generated code around
scrtpt tags, so I figured to change the code above code to:

update_page_tag {
page.visual_effect :highlight, ‘sitio’ + @sitio.id.to_s, :duration => 3

And it does the same exact thing, I get the highltighted item, and I
also keep getting the generated Javascript code rendered right into the