I''ve got a simple toggle option (On/Off) in my admin GUI list action. I would like to click on this graphic and change the status of the option. I got the whole thing working in the controller & db through this beautiful one-liner @item = Item.find(params[:id]).toggle!(''display_status'') The thing I can''t achieve - even after several hours of labouring my brain cell - is how to update the graphics that I click on, ie swapping the On graphics for Off & vice versa. In what way do I do this with Rails & Prototype ?? I''ve been trying multiple options/scenarios to the best of my abilities, but it still ain''t working. Any ideas and help, please ? Regards eyematz -- Posted via http://www.ruby-forum.com/.
an inline rjs could do it in two lines with replace_html On Tuesday, March 28, 2006, at 9:14 PM, eye matz wrote:>I''ve got a simple toggle option (On/Off) in my admin GUI list action. I >would like to click on this graphic and change the status of the option. > >I got the whole thing working in the controller & db through this >beautiful one-liner > >@item = Item.find(params[:id]).toggle!(''display_status'') > >The thing I can''t achieve - even after several hours of labouring my >brain cell - is how to update the graphics that I click on, ie swapping >the On graphics for Off & vice versa. > >In what way do I do this with Rails & Prototype ?? I''ve been trying >multiple options/scenarios to the best of my abilities, but it still >ain''t working. Any ideas and help, please ? > >Regards > >eyematz > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsMikkel Bruun www.strongside.dk - Football Portal(DK) nflfeed.helenius.org - Football News(DK) ting.minline.dk - Buy Old Stuff!(DK) -- Posted with http://DevLists.com. Sign up and save your time!
eye matz, One easy way is to make the 2 images into one and use CSS to display it (see example below). Then create a function in JavaScript that attaches an onclick event handler to the class of what ever contains your image. The initial display would be "ON" and when clicked the the JavaScript would change the style of .toggle_img to background-position: 0px 20px; You''ll also need a counter in the function to switch it back. .toggle_img {background: url(../i/toggle.gif) 0px 10px no-repeat;} Scott. eye matz wrote:> I''ve got a simple toggle option (On/Off) in my admin GUI list action. I > would like to click on this graphic and change the status of the option. > > I got the whole thing working in the controller & db through this > beautiful one-liner > > @item = Item.find(params[:id]).toggle!(''display_status'') > > The thing I can''t achieve - even after several hours of labouring my > brain cell - is how to update the graphics that I click on, ie swapping > the On graphics for Off & vice versa. > > In what way do I do this with Rails & Prototype ?? I''ve been trying > multiple options/scenarios to the best of my abilities, but it still > ain''t working. Any ideas and help, please ? > > Regards > > eyematz-- Posted via http://www.ruby-forum.com/.