I am looking for some implementation ideas. A view has a dropdown. After selecting a value in the dropdown and clicking a submit button, the form gets submitted and calls a method in the view''s controller. This method would display a table of data in the same view depending upon the selection made in the drop down. This works fine. There is another case where in the dropdown in the view can have a value preselected by using some cookies set on the browser. So now, even without clicking the submit button, the above mentioned method in the controller should be called and a table of data should be displayed according to the default value selected in the dropdown. How can this be achieved? -- 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 -~----------~----~----~----~------~----~------~--~---
> I am looking for some implementation ideas. > > A view has a dropdown. After selecting a value in the dropdown and > clicking a submit button, the form gets submitted and calls a method in > the view''s controller. This method would display a table of data in the > same view depending upon the selection made in the drop down. This > works fine. > > There is another case where in the dropdown in the view can have a value > preselected by using some cookies set on the browser. So now, even > without clicking the submit button, the above mentioned method in the > controller should be called and a table of data should be displayed > according to the default value selected in the dropdown. How can this be > achieved?Shr, Given you are looking for idea, here is a few: - Have your controller check for the cookie, and run the required code just as if the page had been submitted and return the desired result - If it is an AJAX submit, then have an onload event which checks for the cookie and does the submission via javascript once the page is loaded - Least preferred (I can''t think of a scenario where I would actually recommend this, but just in case): Have javascript check the cookie on load, change the value of the select, and then submit the form. Hope that has helped --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> - Least preferred (I can''t think of a scenario where I would actually > recommend this, but just in case): Have javascript check the cookie on > load, change the value of the select, and then submit the form. >Thanks Glenn. But the question is, how can the cookie value be accessed inside the javascript function? -- 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 -~----------~----~----~----~------~----~------~--~---