Skip to content

Commit

Permalink
Documentation for <Dropdown/> and onChange callback
Browse files Browse the repository at this point in the history
  • Loading branch information
soyjavi committed Jun 30, 2015
1 parent 9fc0199 commit f3ce007
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
44 changes: 44 additions & 0 deletions components/dropdown/doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Dropdown


```
var DropDown = require('react-toolbox/components/dropdown');
var data = [
{ '1': 'Never' },
{ '2': 'Every Night' },
{ '3': 'Weeknights' },
{ '4': 'Weekends' },
{ '5': 'Weekly' },
];
<DropDown dataSource={data} value='2' />
```

## Properties

| Name | Type | Default | Description |
|:- |:-: | :- |:-|
| **type** | String | "normal" | Type of the component, overwrite this property if you need set a different stylesheet.
| **className** | String | | Set the class-styles of the Component.
| **dataSource** | Object | | JSON data representing all items in the dropdown.
| **value** | String | | Default value using JSON data.
| **label** | String | | The text string to use for the floating label element.
| **disabled** | Boolean | false | Set components disabled.
| **onChange** | Function | | Callback function that is fired when the components's value changes.

## Methods

#### getValue
Returns the value of the input.

```
dropdown_instance.getValue();
```

#### setValue
Sets the value of the input element.

```
dropdown_instance.setValue(newValue);
```
8 changes: 5 additions & 3 deletions components/dropdown/index.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = React.createClass
value : React.PropTypes.string
label : React.PropTypes.string
disabled : React.PropTypes.disabled
onChange : React.PropTypes.func

getDefaultProps: ->
type : "normal"
Expand All @@ -42,9 +43,10 @@ module.exports = React.createClass
active : false
value : target.getAttribute "id"
ripple :
left : event.pageX - client?.left
top : event.pageY - client?.top
width : (client?.width * 2)
left : event.pageX - client?.left
top : event.pageY - client?.top
width : (client?.width * 2)
@props.onChange event, @

# -- Render
render: ->
Expand Down
5 changes: 0 additions & 5 deletions spec/components/dropdown.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ module.exports = React.createClass
"EN-en" : "USA"
"FR-fr" : "France"

# -- Events
onAutocompleteValues: (ref, method) ->
console.log @refs.autocomplete_multiple.getValue()
console.log @refs.autocomplete_simple.getValue()

# -- Render
render: ->
countries_selected = ["USA", "Tongo"]
Expand Down

0 comments on commit f3ce007

Please sign in to comment.