I have a situation where when the user selects a state for a model by choosing a particular menu item in the view, I want to either show or hide a DIV containing other relevant attribute choices... pretty basic stuff, but I''m still a newbie on a lot of the rails view/ui stuff. I think I need a combination of observe_field on the attribute being changed by the menu and then some kind of Prototype toggle effect. And I also need to check the match the user''s menu choice against a condition that says whether or not to show the secondary set of choices in the DIV. Can anyone show me what the code fragment would look like to do this? TIA --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
lunaclaire, how about In the view: <div id=''test_div''> this is the text to hide </div> Click toggle to hide the text: <%= link_to_remote "Toggle", :url=>{:action=>:toggle} %> In the controller: def toggle render :update do |page| page.hide ''test_div'' end end That is very simplistice but it may get you started. If you want to toggle both ways then you need to be a bit smarter. From your description, I suspect you actually want a drop down select box. So you will need to use observe field to call a method that will check the selected value and render hide or show accordingly. hth tonypm --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
On 9/24/07, tonypm <tonypmartin-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> > lunaclaire, > > how about > > In the view: > > <div id=''test_div''> > this is the text to hide > </div> > Click toggle to hide the text: > <%= link_to_remote "Toggle", :url=>{:action=>:toggle} %>Whoa, no need for a round-trip to the server just to toggle a div. This will do the toggle on the client side: <%= link_to_function ''Toggle'', ''Element.toggle("test_div")'' %> Element.toggle is a Prototype function. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Bob Showalter wrote:> On 9/24/07, tonypm <tonypmartin-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote: >> Click toggle to hide the text: >> <%= link_to_remote "Toggle", :url=>{:action=>:toggle} %> > > Whoa, no need for a round-trip to the server just to toggle a div. > This will do the toggle on the client side: > > <%= link_to_function ''Toggle'', ''Element.toggle("test_div")'' %> > > Element.toggle is a Prototype function.Certainly not normally, but one of the OP''s requirements was: "And I also need to check the match the user''s menu choice against a condition that says whether or not to show the secondary set of choices in the DIV." In my opinion, though, you would be better off incorporating that logic in the original request. (Of course, I''m a newb.) -- Posted via http://www.ruby-forum.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?hl=en -~----------~----~----~----~------~----~------~--~---
On 9/24/07, Dave Smith <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Bob Showalter wrote: > > Whoa, no need for a round-trip to the server just to toggle a div. > > Certainly not normally, but one of the OP''s requirements was: > "And I also need to check the match the user''s menu choice against a > condition that says whether or not to show the secondary set of > choices in the DIV."Indeed. I failed to read the OP carefully. Thanks. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---