RJS templates not found


#1

I am running Rails 1.10 and wanted to check out the RJS templates.
Rails doesn’t seem to find them.

I did issue the rake comment update_javascripts and that did not correct
the problem. RJS is part of 1.1 right?

Any ideas?

Thanks.


#2

Arch S. wrote:

I am running Rails 1.10 and wanted to check out the RJS templates.
Rails doesn’t seem to find them.

I did issue the rake comment update_javascripts and that did not correct
the problem. RJS is part of 1.1 right?

Any ideas?

Thanks.

Apparently I was still on 1.0. So I am getting the RJS templates
recgonized now, however I am now getting weird output:

page display:

try { new Insertion.Bottom(“test_1”, "Fox

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

alert(‘RJS error:\n\n’ + e.toString()); alert(‘new
Insertion.Bottom(“test_1”, "Fox
");\nnew Effect.Highlight(“list”,{duration:3});’); throw e }

controller:
def take_test2

end

rjs template:
page.insert_html :bottom, ‘test_1’,
content_tag(“li”, “Fox”)
page.visual_effect :highlight, ‘list’, :duration => 3


#3

I did some more testing. Even turned debugging off for RJS templates
but still I am getting the source displayed on my page.

So for this RJS template:

rjs template

page.insert_html :bottom, “test_1”, :partial => “take_test”
page.visual_effect :highlight, “test_1”, :duration => 10

rhtml partial

Post

post text

I am getting this displayed in the browser:

new Insertion.Bottom(“test_1”, "
\n
Post
\n

post text
\n
"); new Effect.Highlight(“test_1”,{duration:10});


#4

Arch S. wrote:

I did some more testing. Even turned debugging off for RJS templates
but still I am getting the source displayed on my page.

So for this RJS template:

rjs template

page.insert_html :bottom, “test_1”, :partial => “take_test”
page.visual_effect :highlight, “test_1”, :duration => 10

rhtml partial

Post

post text

I am getting this displayed in the browser:

new Insertion.Bottom(“test_1”, "
\n
Post
\n

post text
\n
"); new Effect.Highlight(“test_1”,{duration:10});

When you link to the action which uses RJS, use link_to_remote instead
of link_to.

Jeff C.man


#5

Jeff C.man wrote:

When you link to the action which uses RJS, use link_to_remote instead
of link_to.

Jeff C.man

Yep I am using this call:

<%= link_to_remote("Take Kwiz RJS",:update =>"test_1",:url =>{ :action => "take_test2", :id => test.id}) %>


#6

On Apr 16, 2006, at 11:00 PM, Alain R. wrote:

Alain


Did you make sure to put the  <%= javascript_include_tag :defaults %

in the head of the page getting served?

-Ezra


#7

Arch
>

<%= link_to_remote(“Take Kwiz RJS”,:update
=>“test_1”,:url =>{
> :action => “take_test2”, :id => test.id}) %>


>

To summarize, your RJS ends up as plain test in your web page instead of
being inserted and executed.
Don’t you’re have a filter somewhere that sets the content type to text?

Alain


#8

Alain R. wrote:

Arch
>

<%= link_to_remote(“Take Kwiz RJS”,:update
=>“test_1”,:url =>{
> :action => “take_test2”, :id => test.id}) %>


>

To summarize, your RJS ends up as plain test in your web page instead of
being inserted and executed.
Don’t you’re have a filter somewhere that sets the content type to text?

Alain

Correct. The content type is being set to text in my header:

I’ve also tried

And that did not help either.


#9

Arch S. wrote:

Jeff C.man wrote:

When you link to the action which uses RJS, use link_to_remote instead
of link_to.

Jeff C.man

Yep I am using this call:

<%= link_to_remote("Take Kwiz RJS",:update =>"test_1",:url =>{ :action => "take_test2", :id => test.id}) %>

Try removing the :update parameter from your link_to_remote call.

I believe what’s happening is that link_to_remote is sending the result
of the call into the DIV “test_1”, like it would if you’d called a
partial. But since you’re dealing with RJS, your RJS calls will specify
which DIV to update.

Jeff C.man


#10

Ezra Z. wrote:

On Apr 16, 2006, at 11:00 PM, Alain R. wrote:

Alain


Did you make sure to put the <%= javascript_include_tag :defaults %

in the head of the page getting served?

-Ezra

Yes, here is my layout:

Rails Application <%= stylesheet_link_tag "main", :media => "all" %> <%= javascript_include_tag :defaults %>

#11

Jeff C.man wrote:

Try removing the :update parameter from your link_to_remote call.

I believe what’s happening is that link_to_remote is sending the result
of the call into the DIV “test_1”, like it would if you’d called a
partial. But since you’re dealing with RJS, your RJS calls will specify
which DIV to update.

Jeff C.man

That was it! Damn this one was really throwing me.

Basically I had my whole app working with partials but wanted to try the
RJS templates in 1.1.0, so the :udpate parameters were everywhere and
thus none of my templates were working.

What I don’t understand though is the RJS template was still being hit .
. . oh wait I see . . . it was treating the the code block as the input
and not actually running the code. Right?


#12

Arch S. wrote:

Jeff C.man wrote:

Try removing the :update parameter from your link_to_remote call.

I believe what’s happening is that link_to_remote is sending the result
of the call into the DIV “test_1”, like it would if you’d called a
partial. But since you’re dealing with RJS, your RJS calls will specify
which DIV to update.

Jeff C.man

That was it! Damn this one was really throwing me.

Basically I had my whole app working with partials but wanted to try the
RJS templates in 1.1.0, so the :udpate parameters were everywhere and
thus none of my templates were working.

What I don’t understand though is the RJS template was still being hit .
. . oh wait I see . . . it was treating the the code block as the input
and not actually running the code. Right?

I believe that’s it–it was taking the JavaScript generated by the RJS
template as the content and updating the specified DIV with it–rather
than executing the JavaScript as code.

I got confused by this at the start myself. :slight_smile:

Jeff