context = window rest = window.JK.Rest() logger = context.JK.logger @SelectLocation = React.createClass({ mixins: [Reflux.listenTo(@LocationStore,"onLocationsChanged")] propTypes: { onItemChanged: React.PropTypes.func.isRequired } getInitialState:() -> {selectedCountry: null, countries:{US: {name: 'United States', region: null}}} onLocationsChanged: (countries) -> @setState({countries: countries}) onCountryChanged: (e) -> val = $(e.target).val() @changed(val, null) @setState({selectedCountry: val, selectedRegion: null }) if val? LocationActions.selectCountry(val) onRegionChanged: (e) -> val = $(e.target).val() @changed(@state.selectedCountry, val) @setState({selectedRegion: val }) changed: (country, region) -> if country == '' country = null if region == '' region = null @props.onItemChanged(country, region) render: () -> countries = [``] for countryId, countryInfo of @state.countries countries.push(``) country = @state.countries[@state.selectedCountry] regions = [``] if country? && country.regions for region in country.regions regions.push(``) disabled = regions.length == 1 `

Country:

State/Region:

` })