JSFiddle - React, Tailwind, and code Playground
by majorye
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.1/react-with-addons.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.1/JSXTransformer.js"></script>
<script src="https://facebook.github.io/react/js/jsfiddle-integration.js"></script>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
JavaScript 1.7
var datas=[
{
checked: 'checked',
data: '001'
},
{
checked: '',
data: '001'
}
]
var Hello = React.createClass({
getInitialState: function() {
return {
datas: this.props.datas
}
},
handleClick: function() {
this.setState(
{
datas: [
{
checked: 'checked',
data: '002'
},
{
checked: 'checked',
data: '002'
}
]
}
)
},
render: function() {
return (<div>
{
this.state.datas.map(function(item){
return (<div>
<input type="checkbox" defaultChecked={item.checked} />
<span>{item.data}</span>
</div>)
})
}
<button onClick={this.handleClick.bind(this)}>select all</button>
</div>);
}
});
React.render(<Hello name="World" datas={datas}/>, document.getElementById('container'));