Using shared RJS templates

I’ve got an action in my application controller that needs to call a
shared RJS template. Typically it’s actually being called by subclasses
of the application controller.

I’ve tried this…

def action
…code…
render :partial => “shared/template”
end

with ‘_template.rjs’ existing in the shared folder.

The problem that crops up is that it simply inserts the contents of the
RJS template into the appropriate spot as flat text without actually
executing the javascript.

I’m on edge rails ATM.

Anyone out there playing with RJS templates encountered this before?

Any reason you have it as a partial? RJS’s are never meant to be
rendered to
the screen (from what I understand), so really, there would be no reason
to
have them as partials. This may or may not be your problem, but try
making
it a regular template and see what happens.

-Nick

On 8 Feb 2006 00:54:27 -0000, Kevin O. <

On Tuesday, February 07, 2006, at 8:17 PM, Nick S. wrote:

Any reason you have it as a partial? RJS’s are never meant to be
rendered to
the screen (from what I understand), so really, there would be no reason to
have them as partials. This may or may not be your problem, but try making
it a regular template and see what happens.

-Nick

I finally figured this out. The link_to_remote calls that were calling
the ajax action were specifying an :update parameter. When you do this,
it replaces the contents of the target object with the javascript from
the RJS template. Removing that parameter makes things work just fine.

BTW, leaving the render call as

render :partial=>“shared/template”

works just fine with RJS templates, although I think it makes more sense
to have the call look like this…

render “shared/template”

_Kevin

Cool, glad you got it working, and nice to know that partials do
infact work. But as you said, the concept just seems “off” to me to
have a partial RJS template.

On 8 Feb 2006 03:42:52 -0000, Kevin O.