Hi, Here is what I would like: 2 radio buttons: "yes" and "no" There will be 2 containers: <div id="yes" style="display: none;">Yes stuff</div> <div id="no" style="display: none;">No stuff</div> What I want is whenever the "yes" radio button is selected, on the "yes" div should be made visible. When the "no" radio button is clicked, I want only the "no" div visible. I''ve had many shots, but nothing works. I was using RJS, because more than one update is required. I have to make one appear and one disappear, which is 2 calls. This way you can toggle back and forth. The problem is calling the template. I couldn''t find a way to do something like this that worked: <%= radio_button "project", "yes_or_no", "1", :onclick => :url { :action => "show_yes" } %> Then I tried: <%observe_field(''project_yes_or_no_1'', :url => { :action => "show_yes"}) %> This only works some of the time, and only once. Once the template is called it never works again (if I click back and forth between the radio buttons) I''m sure the RJS template works ebcause I tried it with a link_to_remote. I''m out of ideas... Thanks in advance. Have a great day, Brian -- Posted via http://www.ruby-forum.com/.
Does the "yes" stuff and "no" stuff really require another server roundtrip? It might just be easier to serve them both and use Javascript to turn them on and off as appropriate. You don''t even have to set up observers if you don''t want to. A simple onclick= should get you to your js function. -- View this message in context: http://www.nabble.com/Radio-buttons-and-AJAX-tf2031230.html#a5589246 Sent from the RubyOnRails Users forum at Nabble.com.
Hi Steve, Thanks for the tip. The reason I havn''t just used JS was I was hoping to use script.aculo.us, but you can''t use more than one effect for every onclick can you? Or should I just generate a Javascript function that runs both of these. Brian Steve Ross wrote:> Does the "yes" stuff and "no" stuff really require another server > roundtrip? > It might just be easier to serve them both and use Javascript to turn > them > on and off as appropriate. You don''t even have to set up observers if > you > don''t want to. A simple onclick= should get you to your js function. > -- > View this message in context: > http://www.nabble.com/Radio-buttons-and-AJAX-tf2031230.html#a5589246 > Sent from the RubyOnRails Users forum at Nabble.com.-- Posted via http://www.ruby-forum.com/.
Look into queuing effects. You can use multiple effects, but I haven''t done it. Brian Zimmer-2 wrote:> > The reason I havn''t just used JS was I was hoping to use > script.aculo.us, but you can''t use more than one effect for every > onclick can you? > > Or should I just generate a Javascript function that runs both of these. >-- View this message in context: http://www.nabble.com/Radio-buttons-and-AJAX-tf2031230.html#a5596934 Sent from the RubyOnRails Users forum at Nabble.com.