Skip to content

Commit f3ce007

Browse files
committed
Documentation for <Dropdown/> and onChange callback
1 parent 9fc0199 commit f3ce007

File tree

3 files changed

+49
-8
lines changed

3 files changed

+49
-8
lines changed

components/dropdown/doc.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Dropdown
2+
3+
4+
```
5+
var DropDown = require('react-toolbox/components/dropdown');
6+
7+
var data = [
8+
{ '1': 'Never' },
9+
{ '2': 'Every Night' },
10+
{ '3': 'Weeknights' },
11+
{ '4': 'Weekends' },
12+
{ '5': 'Weekly' },
13+
];
14+
15+
<DropDown dataSource={data} value='2' />
16+
```
17+
18+
## Properties
19+
20+
| Name | Type | Default | Description |
21+
|:- |:-: | :- |:-|
22+
| **type** | String | "normal" | Type of the component, overwrite this property if you need set a different stylesheet.
23+
| **className** | String | | Set the class-styles of the Component.
24+
| **dataSource** | Object | | JSON data representing all items in the dropdown.
25+
| **value** | String | | Default value using JSON data.
26+
| **label** | String | | The text string to use for the floating label element.
27+
| **disabled** | Boolean | false | Set components disabled.
28+
| **onChange** | Function | | Callback function that is fired when the components's value changes.
29+
30+
## Methods
31+
32+
#### getValue
33+
Returns the value of the input.
34+
35+
```
36+
dropdown_instance.getValue();
37+
```
38+
39+
#### setValue
40+
Sets the value of the input element.
41+
42+
```
43+
dropdown_instance.setValue(newValue);
44+
```

components/dropdown/index.cjsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = React.createClass
1818
value : React.PropTypes.string
1919
label : React.PropTypes.string
2020
disabled : React.PropTypes.disabled
21+
onChange : React.PropTypes.func
2122

2223
getDefaultProps: ->
2324
type : "normal"
@@ -42,9 +43,10 @@ module.exports = React.createClass
4243
active : false
4344
value : target.getAttribute "id"
4445
ripple :
45-
left : event.pageX - client?.left
46-
top : event.pageY - client?.top
47-
width : (client?.width * 2)
46+
left : event.pageX - client?.left
47+
top : event.pageY - client?.top
48+
width : (client?.width * 2)
49+
@props.onChange event, @
4850

4951
# -- Render
5052
render: ->

spec/components/dropdown.cjsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ module.exports = React.createClass
1616
"EN-en" : "USA"
1717
"FR-fr" : "France"
1818

19-
# -- Events
20-
onAutocompleteValues: (ref, method) ->
21-
console.log @refs.autocomplete_multiple.getValue()
22-
console.log @refs.autocomplete_simple.getValue()
23-
2419
# -- Render
2520
render: ->
2621
countries_selected = ["USA", "Tongo"]

0 commit comments

Comments
 (0)