Skip to content

Commit

Permalink
Merge pull request #198 from vmakhaev/master
Browse files Browse the repository at this point in the history
add onChange to DatePicker. Fixes #197
  • Loading branch information
hai-cea committed Jan 5, 2015
2 parents 1bf8332 + ba1260d commit 5dbc9f5
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/js/date-picker/date-picker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ var DatePicker = React.createClass({
formatDate: React.PropTypes.func,
mode: React.PropTypes.oneOf(['portrait', 'landscape', 'inline']),
onFocus: React.PropTypes.func,
onTouchTap: React.PropTypes.func
onTouchTap: React.PropTypes.func,
onChange: React.PropTypes.func
},

windowListeners: {
Expand Down Expand Up @@ -66,7 +67,7 @@ var DatePicker = React.createClass({
initialDate={this.state.dialogDate}
onAccept={this._handleDialogAccept} />
</div>

);
},

Expand All @@ -83,6 +84,7 @@ var DatePicker = React.createClass({

_handleDialogAccept: function(d) {
this.setDate(d);
if (this.props.onChange) this.props.onChange(null, d);
},

_handleInputFocus: function(e) {
Expand All @@ -91,11 +93,8 @@ var DatePicker = React.createClass({
},

_handleInputTouchTap: function(e) {
var dateString = this.refs.input.getValue();
var inputDate = dateString ? new Date(dateString) : new Date();

this.setState({
dialogDate: inputDate
dialogDate: this.getDate()
});

this.refs.dialogWindow.show();
Expand Down

0 comments on commit 5dbc9f5

Please sign in to comment.