arvindvyas / Country-State-Select

It will fetch the countries and according to that fetch the state of that countries, currently it is for countries listing
MIT License
69 stars 78 forks source link

Need to Update wiki for city #23

Open arvindvyas opened 9 years ago

arvindvyas commented 9 years ago

Added city select according to country and state, need to update wiki for it .

wonderphil commented 8 years ago

Hi guys,

Back again, just on this I have added the city_id: "city_field_id" to the javascript. Then added

<%= options = { form: f, field_names: { :state => :state_field, :city => :city_field }, label: 'City' } f.input :city_field, CountryStateSelect.city_options(options) %> to my form, which worked well, only problem and maybe I am missing something, when you select the country, the state collection is populated, and the form shows the first state, but then doesn't show the cities for that state, you have to select another state, before the javascript updates the city collection.

For example, I select United Kingdom, then that shows England, now if I want to select on of the city under england, I have to first select another state, then select england again, before the cities are listed.

Have I missed something in the Javascript that would sort this?

Thanks

Phil