Forum: Ruby on Rails Using shared RJS templates

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.
Kevin O. (Guest)
on 2006-02-08 02:56
(Received via mailing list)
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?
Nick S. (Guest)
on 2006-02-08 03:17
(Received via mailing list)
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. <
Kevin O. (Guest)
on 2006-02-08 05:43
(Received via mailing list)
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
Nick S. (Guest)
on 2006-02-08 20:01
(Received via mailing list)
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.
This topic is locked and can not be replied to.