Created
October 22, 2014 16:31
-
-
Save faust45/b00eb93c5cb682b86c16 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 SwitchGroup = React.createClass({ | |
| componentDidMount: function() { | |
| var onChange = this.props.onChange; | |
| var el = this.getDOMNode().querySelectorAll("input[type=radio]"); | |
| $(el).on("change", function(e) { | |
| console.log("on hange happen"); | |
| if(onChange) { | |
| onChange(e); | |
| } | |
| }); | |
| }, | |
| render: function() { | |
| var selected = this.props.selected; | |
| var buttons = _.map(this.props.options, function(data) { | |
| var label = data[0], value = data[1]; | |
| var classes = cx({ | |
| 'btn btn-default': true, | |
| 'active': (value == selected), | |
| }); | |
| return ( | |
| <label className={classes}> | |
| <input type="radio" value={value} />{label} | |
| </label> | |
| ) | |
| }); | |
| return ( | |
| <div className="btn-group" data-toggle="buttons" onChange={this.handleChange}> | |
| {buttons} | |
| </div> | |
| ) | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment