forked from dmwyatt/reactselect2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.js
43 lines (38 loc) · 919 Bytes
/
demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @jsx React.DOM
*/
var Demo = React.createClass({
getInitialState: function () {
return {
selections: []
}
},
handleSelections: function (e, selections) {
this.setState({
selections: selections
})
},
render: function () {
var data =[
{id: 0, text: "Option 1"},
{id: 1, text: "Option 2"},
{id: 2, text: "Option 3"},
{id: 3, text: "Option 4"}
];
return (
<div>
<Select2Component
id="the-hidden-input-id"
dataSet={data}
onSelection={this.handleSelections}
placeholder="Select some options"
multiple={true}
styleWidth="25%"
val={[1, 3]}
/>
{JSON.stringify(this.state.selections, undefined, 2)}
</div>
);
}
});
React.renderComponent(<Demo />, document.getElementById("render_area"));