Hello everyone :) I have this ajax issue, I''d be glad if someone would be willing to help, thanks :) What I try to do: Have a select box with a list of countries. When the country select box value is changed, have the state box appear. Up to this point, I got this successfully. When the state box gets changed, have the city box appear for selection. This is what I couldn''t acheive... How I coded it: In my rhtml page I got this code: <%= select "assoc", "country_id", @country_options, {:include_blank => true} %> <%= observe_field(:assoc_country_id, :frequency => 0.5, :update => :states, :url => { :action => :show_states_select }, :with => "''country_id='' + value") %> In show_states_select.rhtml, I got this: <%= select ''assoc'', ''state_id'', @state_options, {:include_blank => true} %> </td> <td> <div id="cities"></div> <%= observe_field(:assoc_state_id, :frequency => 0.5, :update => :cities, :url => { :action => :show_cities_select }, :with => "''state_id='' + value") %> And show_cities_select.rhtml: <%= select ''user'', ''city_id'', @city_options, {:include_blank => true} %> I think it does not appear because maybe the second observe_field comes from ajax request and maybe is not interpreted, I don''t know, if someone could help me, I''d appreciate... Thank you :) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Come on, no idea for this ? On Feb 18, 2008 8:00 PM, pierreact <pierreact-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hello everyone :) > > I have this ajax issue, I''d be glad if someone would be willing to > help, thanks :) > > What I try to do: > Have a select box with a list of countries. > When the country select box value is changed, have the state box > appear. > Up to this point, I got this successfully. > > When the state box gets changed, have the city box appear for > selection. This is what I couldn''t acheive... > > > How I coded it: > In my rhtml page I got this code: > > <%= select "assoc", "country_id", @country_options, {:include_blank => > true} %> > <%= observe_field(:assoc_country_id, > :frequency => 0.5, > :update => :states, > :url => { :action => > :show_states_select }, > :with => "''country_id='' + value") %> > > In show_states_select.rhtml, I got this: > <%= select ''assoc'', ''state_id'', @state_options, {:include_blank => > true} %> > </td> > <td> > <div id="cities"></div> > > <%= observe_field(:assoc_state_id, > :frequency => 0.5, > :update => :cities, > :url => { :action => > :show_cities_select }, > :with => "''state_id='' + value") %> > > And show_cities_select.rhtml: > <%= select ''user'', ''city_id'', @city_options, {:include_blank => true} > %> > > I think it does not appear because maybe the second observe_field > comes from ajax request and maybe is not interpreted, I don''t know, if > someone could help me, I''d appreciate... > > Thank you :) > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
(My apologies if this gets double-posted - I sent it last night but haven''t gotten any indication that it was received. It might be something weird with GMail, however) --- Hello, everyone. I''m currently working on a politically-themed social networking site that I hope will grow in the near future. I''ve decided to use (obviously) Ruby on Rails to write the site, although I come from an ASP.NET background and this is my first real foray into RoR and anything outside of the MS world (I''ve dabbled very little in Linux, so I know the basics but not much else). The issue I''m running into, however, is that I want to have an integrated blogging module that allows for multiple blogs by multiple users, each with different URLs - a core feature of the site is that it will host various related blogs by different people, hopefully with subdomains such as johndoe.mysite.com (which would redirect to something like mysite.com/blogs/johndoe). I''d also like to have integrated forums, so that when a user joins the site, their session spans to the forums, and for posting comments to blogs (we only want to allow registered users to post comments), and the like. The integrated forums is a must because users can have special icons based on information in their profile (if they own a business, for example, and want to associate with the site), but other than that there are no specific requirements outside of a normal forum. My web host (HostingRails) has some options built-in, but they''re all PHP based and I''m finding that they don''t really integrate well with the RoR application (one of the PHP boards especially, since it uses a similar URL method to Rails, and thus Rails tries to parse it, only to fail and give me a 404); I could use them in a pinch, but I''d really like a unified look and feel to the site. As I said, I''m relatively new to RoR development (I''ve read through the Agile Web Development With Rails book twice now) so, while I could probably try my hand at writing custom functionality, I figure I''d take a chance and see if there''s anything that I can use as the base first. Is there anything out there that would fulfil my needs, or would I be better off rolling up my sleeves and coding my own? I have an idea of what it would take, I''m just not confident enough in my RoR skills to think I could do a very good job of it, as I''m still pretty much a newbie. I''m hoping that someone can point me in the right direction, or at least offer some suggestions I can look into. Many thanks! - Wayne M Co-Founder, LibertyTruth.org No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.516 / Virus Database: 269.20.7/1285 - Release Date: 2/18/2008 5:50 AM --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
why not have an onChange="showState();" on the country list. then in some JS have function showState(){ // use CSS to show the box. document.getElementById(''user_city_id'').style.display=''block''; } to make it "appear" and you can "hide" the city box by adding some JS at the bottom of the page. // use CSS to hide the box. document.getElementById(''user_city_id'').style.display=''none''; This way if the user does not have JS turned on they will still see the city box. John Ivanoff On Feb 19, 6:36 am, "Pierre Pierre" <pierre...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Come on, no idea for this ? > > On Feb 18, 2008 8:00 PM, pierreact <pierre...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hello everyone :) > > > I have this ajax issue, I''d be glad if someone would be willing to > > help, thanks :) > > > What I try to do: > > Have a select box with a list of countries. > > When the country select box value is changed, have the state box > > appear. > > Up to this point, I got this successfully. > > > When the state box gets changed, have the city box appear for > > selection. This is what I couldn''t acheive... > > > How I coded it: > > In my rhtml page I got this code: > > > <%= select "assoc", "country_id", @country_options, {:include_blank => > > true} %> > > <%= observe_field(:assoc_country_id, > > :frequency => 0.5, > > :update => :states, > > :url => { :action => > > :show_states_select }, > > :with => "''country_id='' + value") %> > > > In show_states_select.rhtml, I got this: > > <%= select ''assoc'', ''state_id'', @state_options, {:include_blank => > > true} %> > > </td> > > <td> > > <div id="cities"></div> > > > <%= observe_field(:assoc_state_id, > > :frequency => 0.5, > > :update => :cities, > > :url => { :action => > > :show_cities_select }, > > :with => "''state_id='' + value") %> > > > And show_cities_select.rhtml: > > <%= select ''user'', ''city_id'', @city_options, {:include_blank => true} > > %> > > > I think it does not appear because maybe the second observe_field > > comes from ajax request and maybe is not interpreted, I don''t know, if > > someone could help me, I''d appreciate... > > > Thank you :)--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Check out railscasts.com. Ryan Bates did an excellent cast on exactly this topic a few weeks ago (no. 88 - Dynamic Select Menus). Better than AJAX, since it is all processed client-side. (You''d also be able to use the caching methods, since your available options aren''t going to change very often.) On Feb 19, 8:00 am, pierreact <pierre...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello everyone :) > > I have this ajax issue, I''d be glad if someone would be willing to > help, thanks :) > > What I try to do: > Have a select box with a list of countries. > When the country select box value is changed, have the state box > appear. > Up to this point, I got this successfully. > > When the state box gets changed, have the city box appear for > selection. This is what I couldn''t acheive... > > How I coded it: > In my rhtml page I got this code: > > <%= select "assoc", "country_id", @country_options, {:include_blank => > true} %> > <%= observe_field(:assoc_country_id, > :frequency => 0.5, > :update => :states, > :url => { :action => :show_states_select }, > :with => "''country_id='' + value") %> > > In show_states_select.rhtml, I got this: > <%= select ''assoc'', ''state_id'', @state_options, {:include_blank => > true} %> > </td> > <td> > <div id="cities"></div> > > <%= observe_field(:assoc_state_id, > :frequency => 0.5, > :update => :cities, > :url => { :action => :show_cities_select }, > :with => "''state_id='' + value") %> > > And show_cities_select.rhtml: > <%= select ''user'', ''city_id'', @city_options, {:include_blank => true} > %> > > I think it does not appear because maybe the second observe_field > comes from ajax request and maybe is not interpreted, I don''t know, if > someone could help me, I''d appreciate... > > Thank you :)--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Unless I misunderstand the problem, the issue is that he wants to dynamically populate the city and state selects based on the user''s choices. Pick country A and you get a list of n States populated into the state select. Pick state B from the newly visible state select and you get m cities in that state populated into the newly visible city select. @pierre -- I think that IE gets very cranky about executing JS that was not part of the original page. You may find that you need to compromise here. Create the selects and the observers and hide their containing divs. Your AJAX method can then either replace the previously empty select OR add the options to it (rather than rendering a new select with options and its observer). The return js would finish up by making the containing div visible. HTH, AndyV On Feb 19, 10:26 am, John Ivanoff <john.ivan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> why not have an > onChange="showState();" > on the country list. > > then in some JS have > function showState(){ > // use CSS to show the box. > document.getElementById(''user_city_id'').style.display=''block''; > } > to make it "appear" > > and you can "hide" the city box by adding some JS at the bottom of the > page. > // use CSS to hide the box. > document.getElementById(''user_city_id'').style.display=''none''; > This way if the user does not have JS turned on they will still see > the city box. > > John Ivanoff > > On Feb 19, 6:36 am, "Pierre Pierre" <pierre...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Come on, no idea for this ? > > > On Feb 18, 2008 8:00 PM, pierreact <pierre...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hello everyone :) > > > > I have this ajax issue, I''d be glad if someone would be willing to > > > help, thanks :) > > > > What I try to do: > > > Have a select box with a list of countries. > > > When the country select box value is changed, have the state box > > > appear. > > > Up to this point, I got this successfully. > > > > When the state box gets changed, have the city box appear for > > > selection. This is what I couldn''t acheive... > > > > How I coded it: > > > In my rhtml page I got this code: > > > > <%= select "assoc", "country_id", @country_options, {:include_blank => > > > true} %> > > > <%= observe_field(:assoc_country_id, > > > :frequency => 0.5, > > > :update => :states, > > > :url => { :action => > > > :show_states_select }, > > > :with => "''country_id='' + value") %> > > > > In show_states_select.rhtml, I got this: > > > <%= select ''assoc'', ''state_id'', @state_options, {:include_blank => > > > true} %> > > > </td> > > > <td> > > > <div id="cities"></div> > > > > <%= observe_field(:assoc_state_id, > > > :frequency => 0.5, > > > :update => :cities, > > > :url => { :action => > > > :show_cities_select }, > > > :with => "''state_id='' + value") %> > > > > And show_cities_select.rhtml: > > > <%= select ''user'', ''city_id'', @city_options, {:include_blank => true} > > > %> > > > > I think it does not appear because maybe the second observe_field > > > comes from ajax request and maybe is not interpreted, I don''t know, if > > > someone could help me, I''d appreciate... > > > > Thank you :)--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---