I have an A-Z list that controls a list of check_box_tag values. So a user clicks on a A-Z link, the list of checkboxes are displayed, they tic the checkboxes and the value is stored in the session variable, and they go on like that until they submit. Once they submit, the session variable is looped over and the values are saved. The A-Z list uses link_to_remote to update the list. The check_box_tags uses a remote_function call to store the checked value in a session variable. This all works fine. The problem is that when the user selects a checkbox and then selects a new A-Z link and then goes back to the same A-Z link the checkbox is no longer selected. <%= check_box_tag(db.id, db.id, session[:selected].include? (db), :onclick => remote_function( :url => {:action => ''selected'',:cid => db})) %> <%=db.title%> def selected session[:selected] << params[:cid] render :nothing => true, :layout => false end I know the remote_function call is adding the object to the session[:selected] array, but for some reason session[:selected].include?(db) is not returning true. Any suggestions? Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Oct-10 06:52 UTC
Re: Save selected checkboxes after remote_function call
On Oct 10, 12:30 am, Kim <Kim.Gri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I know the remote_function call is adding the object to the > session[:selected] array, but for some reason > session[:selected].include?(db) is not returning true. >because db is apparently an activerecord object, but your session contains ids Fred> Any suggestions? Thanks in advance.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks Fred, but no go. I have tried both: <%= check_box_tag(db.id, db.id, session[:selected].include? (db), :onclick => remote_function( :url => {:action => ''selected'',:cid => db})) %> <%=db.title%> and <%= check_box_tag(db.id, db.id, session[:selected].include? (db.id), :onclick => remote_function( :url => {:action => ''selected'',:cid => db.id})) %> <%=db.title%> Any other suggestions? On Oct 9, 11:52 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Oct 10, 12:30 am, Kim <Kim.Gri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I know the remote_function call is adding the object to the > > session[:selected] array, but for some reason > > session[:selected].include?(db) is not returning true. > > because db is apparently an activerecord object, but your session > contains ids > > Fred > > > Any suggestions? Thanks in advance.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Kim wrote:> <%= check_box_tag(db.id, db.id, session[:selected].include? > (db.id), :onclick => remote_function( :url => {:action => > ''selected'',:cid > => db.id})) %> <%=db.title%> > > > Any other suggestions?session[:selected].include?(db.id.to_s) -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.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 -~----------~----~----~----~------~----~------~--~---
yep, that was it. Thanks. On Wed, Oct 15, 2008 at 7:44 PM, Mark James <mrj-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org> wrote:> > Kim wrote: > > > <%= check_box_tag(db.id, db.id, session[:selected].include? > > (db.id), :onclick => remote_function( :url => {:action => > > ''selected'',:cid > > => db.id})) %> <%=db.title%> > > > > > > Any other suggestions? > > session[:selected].include?(db.id.to_s) > > -- > Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com > > > >-- Kim Griggs kim.griggs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org "We are all stakeholders in the Karma economy." --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---