Created
October 22, 2014 17:09
-
-
Save faust45/d92f423d896b461efd78 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) { | |
| // if(onChange) { | |
| // onChange(e); | |
| // } | |
| // }); | |
| }, | |
| render: function() { | |
| var selected = this.props.selected; | |
| var name = uuid(); | |
| var onChange = function() { console.log("handle change radio") }; | |
| 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} name={name} onChange={onChange} />{label} | |
| </label> | |
| ) | |
| }); | |
| return ( | |
| <div className="btn-group" data-toggle="buttons"> | |
| {buttons} | |
| </div> | |
| ) | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment