Last active
August 29, 2015 14:17
-
-
Save taylorlapeyre/c21a69ec1ccb8bc20f35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SelectThing = React.createClass({ | |
getInitialState: function() { | |
return { | |
chosenFirstValue: "", | |
chosenSecondValue: "" | |
} | |
}, | |
updateFirstSelectValue: function(e) { | |
var value = $(e.currentTarget).val(); | |
if (this.state.secondSelectValue == "whatever") { | |
// do some logic | |
} | |
this.setState({ | |
chosenFirstValue: value | |
}) | |
}, | |
updateSecondSelectValue: function(e) { | |
var value = $(e.currentTarget).val(); | |
if (this.state.firstSelectValue == "whatever") { | |
// do some logic | |
} | |
this.setState({ | |
chosenSecondValue: value | |
}) | |
}, | |
render: function() { | |
var firstSelectItems = this.props.collection1.map(function(item) { | |
return <option value={item}>{item}</option>; | |
}); | |
var secondSelectItems = this.props.collection2.map(function(item) { | |
return <option value={item}>{item}</option>; | |
}); | |
return ( | |
<div class="select-thing"> | |
<select onInput={updateFirstSelectValue}> | |
{firstSelectItems} | |
</select> | |
<select onInput={updateSecondSelectValue}> | |
{secondSelectItems} | |
</select> | |
</div> | |
) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment