diff --git a/src/js/date-picker/date-picker.jsx b/src/js/date-picker/date-picker.jsx index cf4fe2a9d0d54e..7fc1863b022a25 100644 --- a/src/js/date-picker/date-picker.jsx +++ b/src/js/date-picker/date-picker.jsx @@ -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: { @@ -66,12 +67,12 @@ var DatePicker = React.createClass({ initialDate={this.state.dialogDate} onAccept={this._handleDialogAccept} /> - + ); }, getDate: function() { - return this.state.value; + return this.state.date; }, setDate: function(d) { @@ -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) { @@ -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(); @@ -108,4 +107,4 @@ var DatePicker = React.createClass({ }); -module.exports = DatePicker; \ No newline at end of file +module.exports = DatePicker;