Terry Donaghe
2006-Sep-06 18:14 UTC
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Terry Donaghe
2006-Sep-06 22:12 UTC
Re: RJS Javascript oddity - trying to call Element.setStyle
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: <html> <head> <title>ColorToy</title> <%= javascript_include_tag :defaults %> <%= stylesheet_link_tag ''colortoy'' %> </head> <body> <div id="color_picker"> <%= form_remote_tag(:url => {:action => ''color_show''}) %> <%= submit_tag ''Show Color'' %> <%= end_form_tag %> </div> <div id="show_color"> </div> </body> </html> 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 Donaghe <terry.donaghe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 >-- Terry (TAD) Donaghe http://www.tadspot.com http://www.rubynoob.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Terry Donaghe
2006-Sep-07 02:52 UTC
Re: RJS Javascript oddity - trying to call Element.setStyle
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 Donaghe <terry.donaghe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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: > > <html> > <head> > <title>ColorToy</title> > <%= javascript_include_tag :defaults %> > <%= stylesheet_link_tag ''colortoy'' %> > </head> > <body> > <div id="color_picker"> > <%= form_remote_tag(:url => {:action => ''color_show''}) %> > <%= submit_tag ''Show Color'' %> > <%= end_form_tag %> > </div> > <div id="show_color"> > </div> > </body> > </html> > > 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 Donaghe <terry.donaghe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > 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 > > > > > > -- > Terry (TAD) Donaghe > http://www.tadspot.com > http://www.rubynoob.com >-- Terry (TAD) Donaghe http://www.tadspot.com http://www.rubynoob.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---