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

City bugs #36

Closed aldefouw closed 8 years ago

aldefouw commented 8 years ago

@arvindvyas

Here are the bugs that I was referring to in the other post.

1. When you change the country, the options under city should change to the first state's cities.

Example: If you start out on United States, Alaska shows up.

Switch to Canada and Alberta shows up under the new states.

That's correct.

BUT ... the cities from Alaska still appear under the cities drop down after you have switched to Canada / Alberta. That isn't correct.

The minute that the state changes, it should automatically switch the cities to the new state you've selected.

To fix this, it will involve a fix to the country_state_select.js.erb file. You're going to need to add a trigger of some sort to make the cities update based upon the change of the state / province.

2. For some reason, the #collect_cities method in returns cities correctly to the controller but nowhere else.

I cannot figure out why CS.cities can return the correct cities array when it's called within the controller but returns an empty set [] when it's called from within the view.

By contrast, CountryStateSelect.collect_states(f.object.test_country) works the same in either location.

I've spent hours troubleshooting this issue without any luck.

I didn't see anything wrong with the collect_cities method, but that's weird behavior!

arvindvyas commented 8 years ago

@aldefouw thanks I will look into it.

arvindvyas commented 8 years ago

@aldefouw I have seen the city update issue that is same with state, what we can do is we can provide "Please Select " option , That will look good.

arvindvyas commented 8 years ago

@aldefouw can you show me the codebase where you have try the "2. For some reason, the #collect_cities method in returns cities correctly to the controller but nowhere else." , I might help u on this , Actually I am not getting what exectly what you are looking into it.

arvindvyas commented 8 years ago

@aldefouw there is difference between collect_states and collect_cities when you use

CountryStateSelect.collect_states at that time you need to only sent country id but when you use CountryStateSelect.collect_cities at that time you need to sent two arguments first is 'state_id' and second is "country id " if anything will be nil on this two then it will return nil.

Let me know if you did not get this.