diff options
Diffstat (limited to 'src/module/Select.jsx')
-rw-r--r-- | src/module/Select.jsx | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/module/Select.jsx b/src/module/Select.jsx index 2b69623..be4c025 100644 --- a/src/module/Select.jsx +++ b/src/module/Select.jsx | |||
@@ -22,6 +22,7 @@ const Select = React.createClass({ | |||
22 | propTypes: { | 22 | propTypes: { |
23 | prefixCls: PropTypes.string, | 23 | prefixCls: PropTypes.string, |
24 | options: PropTypes.array, | 24 | options: PropTypes.array, |
25 | gregorianCalendarLocale: PropTypes.object, | ||
25 | selectedIndex: PropTypes.number, | 26 | selectedIndex: PropTypes.number, |
26 | type: PropTypes.string, | 27 | type: PropTypes.string, |
27 | onSelect: PropTypes.func, | 28 | onSelect: PropTypes.func, |
@@ -37,23 +38,19 @@ const Select = React.createClass({ | |||
37 | this.scrollToSelected(200); | 38 | this.scrollToSelected(200); |
38 | }, | 39 | }, |
39 | 40 | ||
40 | onSelect(event) { | 41 | onSelect(value) { |
41 | // do nothing when select selected option | ||
42 | if (event.target.getAttribute('class') === 'selected') { | ||
43 | return; | ||
44 | } | ||
45 | // change combobox selection | ||
46 | const { onSelect, type } = this.props; | 42 | const { onSelect, type } = this.props; |
47 | const value = parseInt(event.target.innerHTML, 10); | ||
48 | onSelect(type, value); | 43 | onSelect(type, value); |
49 | }, | 44 | }, |
50 | 45 | ||
51 | getOptions() { | 46 | getOptions() { |
52 | const { options, selectedIndex } = this.props; | 47 | const { options, selectedIndex, prefixCls } = this.props; |
53 | return options.map((item, index) => { | 48 | return options.map((item, index) => { |
54 | const cls = classnames({ selected: selectedIndex === index}); | 49 | const selected = selectedIndex === index; |
55 | const ref = selectedIndex === index ? 'selected' : null; | 50 | const cls = classnames({ |
56 | return <li ref={ref} className={cls} key={index} onClick={this.onSelect}>{item}</li>; | 51 | [`${prefixCls}-select-option-selected`]: selected, |
52 | }); | ||
53 | return <li className={cls} key={index} onClick={this.onSelect.bind(this, +item)}>{item}</li>; | ||
57 | }); | 54 | }); |
58 | }, | 55 | }, |
59 | 56 | ||