RJS not working

Hi,

I just can’t seem to get my RJS template to work.
I have this in my .rhtml file:
<%= link_to_remote( “1”, {:url => { :controller => “log”, :action =>
“rate”, :id => post.id, :rating => 1}}, :class => ‘one-star’, :name =>
‘Rate this post 1 star out of 3’) %>

My rate.rjs has this (for testing purposes):
page.alert(‘RJS works!’)

That doesn’t that a thing.
So I added this to my .rhtml file:
<%= link_to_remote( “3”, {:url => { :controller => “log”, :action =>
“rate”, :id => post.id, :rating => 3},
:complete=>‘alert(request.responseText)’}, :class => ‘three-stars’,
:name => ‘Rate this post 3 star out of 3’) %>

Now I get a popup saying:
alert(‘RJS Works!’) instead of actually doing the alert.

any ideas?

MJ

Now I get a popup saying:
alert(‘RJS Works!’) instead of actually doing the alert.

What does Firebug show for the request / response? Usually that will
clue you in on the problem.

Michael

MJ wrote:

any ideas?

MJ


Posted via http://www.ruby-forum.com/.

Are you including a tag like this in your layout?

<%= javascript_include_tag :defaults %>

_Kevin

Michael T. wrote:

Now I get a popup saying:
alert(‘RJS Works!’) instead of actually doing the alert.

What does Firebug show for the request / response? Usually that will
clue you in on the problem.

It says alert(“RJS works!”); in the response
But the alert doesn’t show up in the browser.

Michael

_Kevin wrote:

MJ wrote:

any ideas?

MJ


Posted via http://www.ruby-forum.com/.

Are you including a tag like this in your layout?

<%= javascript_include_tag :defaults %>

Yep!

_Kevin

On 10/24/06, MJ [email protected] wrote:

I just can’t seem to get my RJS template to work.
I have this in my .rhtml file:

Rename it .rjs.


Greg D.
http://destiney.com/

Greg D. wrote:

On 10/24/06, MJ [email protected] wrote:

I just can’t seem to get my RJS template to work.
I have this in my .rhtml file:

Rename it .rjs.

I don’t quite understand I have an idex.rhtml, with the link
to the rate controller via a link_to_remote and a rate.rjs file.
This is correct, no?


Greg D.
http://destiney.com/

I don’t quite understand I have an idex.rhtml, with the link
to the rate controller via a link_to_remote and a rate.rjs file.
This is correct, no?

Yes. Try this in your controller instead, and let us know:

def rate
render :update do |page|
page.alert(“RJS WORKS”)
end
end

Michael T. wrote:

I don’t quite understand I have an idex.rhtml, with the link
to the rate controller via a link_to_remote and a rate.rjs file.
This is correct, no?

Yes. Try this in your controller instead, and let us know:

def rate
render :update do |page|
page.alert(“RJS WORKS”)
end
end

I tried it, but still no popup.

Michael T. wrote:

end
I prefer this style myself. RJS templates are more about logic and
functionality, so it makes sense to put them in the controller. The
one exception for me would be a template that I might use in several
different controllers.

_Kevin

Maybe an idea about my setup will help:
I am using Apache 2.2 and Mongrel and reverse_proxy_fix.

Would you email me the necessary files: controller, views, helpers.
I’ll take a look.

Michael

Michael T. wrote:

Maybe an idea about my setup will help:
I am using Apache 2.2 and Mongrel and reverse_proxy_fix.

Would you email me the necessary files: controller, views, helpers.
I’ll take a look.

Michael

No need :slight_smile: I just figured it out. I had old Javascript files,I did an
update an now everything works great!

MJ

Maybe an idea about my setup will help:
I am using Apache 2.2 and Mongrel and reverse_proxy_fix.

On 10/26/06, MJ [email protected] wrote:

No need :slight_smile: I just figured it out. I had old Javascript files,I did an
update an now everything works great!

Great.

Michael

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs