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

'Undefined' is first option in State Dropdown #37

Closed aldefouw closed 8 years ago

aldefouw commented 8 years ago

Hi Arvind -

I think that there may be an issue with the latest version 3.0.2.

When I select the Country, the States are populated, but the first value is "undefined."

Are you able to reproduce that behavior on your end?

I did notice that you did some refactoring to the code a while back. If this is an issue and not just some stupid setup issue on my part, perhaps you might look at that refactored code?

Thanks, Adam

arvindvyas commented 8 years ago

@aldefouw I have tested and it is working fine , let me know how you have generated it so that we can look into it. I have refactor the code which are in master not yet released because I have not tested yet,

Let me know if you can share the steps how you have generated the issue

arvindvyas commented 8 years ago

@aldefouw I am closing this as it is not reproducible, please open it if you got the step to reproduce it .

aldefouw commented 8 years ago

I'll try to get to this later this week.

Just been busy with life outside of the programming world.

My twin brother's wife just gave birth last night ... been running around a lot lately =)

xpopov commented 7 years ago

I had this issue as well. After looking at js sources, I've found that it can be fixed by adding state_place_holder option.

So in my case, coffeescript looks like:

$(document).on 'ready page:load', -> CountryStateSelect({ country_id: "location_country", state_id: "location_state", state_place_holder: "Choose state" })

Without state_place_holder option, I was getting first state option as 'undefined'.

I think in your sources, return options['state_place_holder'] should be something like return options['state_place_holder'] || ''