RJS Javascript oddity - trying to call Element.setStyle

Hi all,

I have a really simple web page. Right now, it’s just a button and a
square
div. What I want to do is to change the background color of the div to
red
when the button is clicked. My form code looks like this:

<%= form_remote_tag :url => {:action => ‘color_show’} %>

color_show.rjs looks like this:

page << “Element.setStyle(‘show_color’, {backgroundColor: ‘blue’})”

When I click the button, the page elements go away and I just get this
screen of text:

try {
Element.setStyle(‘show_color’, {backgroundColor: ‘blue’})
} catch (e) { alert(‘RJS error:\n\n’ + e.toString());
alert(‘Element.setStyle(‘show_color’, {backgroundColor:
‘blue’})’); throw e }

Any ideas what I’m doing wrong? I feel like I’m relatively close to
getting
this working.

Thanks for any help!!


Terry (TAD) Donaghe
http://www.tadspot.com
http://www.rubynoob.com

This is really driving me nuts because I see tons of questions about
similar
issues, but in all of the other cases on form_remote_tag writing
javascript
right out to the browser, the form_remote_tag method had an :update
parameter that needed to be removed. My form_remote_tag does NOT have
any
other parameters other than those shown below. Here’s the sum total of
my
code:

index.rhtml:

ColorToy <%= javascript_include_tag :defaults %> <%= stylesheet_link_tag 'colortoy' %>
<%= form_remote_tag(:url => {:action => 'color_show'}) %> <%= submit_tag 'Show Color' %> <%= end_form_tag %>

color_show.rjs:

page << “Element.setStyle(‘show_color’, {backgroundColor: ‘#555555’})”

There is no code in my controller. Does anyone have a clue what I’m
doing
wrong? I’m going insane, here! Sooooooo close to working! I feel like
I’m
just missing one piece.

Please help!

On 9/6/06, Terry D. [email protected] wrote:

Any ideas what I’m doing wrong? I feel like I’m relatively close to
getting this working.

Thanks for any help!!


Terry (TAD) Donaghe
http://www.tadspot.com
http://www.rubynoob.com


Terry (TAD) Donaghe
http://www.tadspot.com
http://www.rubynoob.com

I’m still not sure what I was doing wrong, but I solved my problem by
completely starting over with an entire new project. Everything works
properly now. If at first you don’t succeed, rewrite your code, restart
the
WEBrick and try again!

On 9/6/06, Terry D. [email protected] wrote:

wrong? I'm going insane, here! Sooooooo close to working! I feel like I'm > > When I click the button, the page elements go away and I just get this > Thanks for any help!! Terry (TAD) Donaghe http://www.tadspot.com http://www.rubynoob.com


Terry (TAD) Donaghe
http://www.tadspot.com
http://www.rubynoob.com