From 5464fc56d03377c73bf6bb1317014059f3becf0c Mon Sep 17 00:00:00 2001 From: Javi Date: Mon, 10 Aug 2015 17:13:44 +0700 Subject: [PATCH] New methods .blur and .focus --- components/input/index.cjsx | 12 +++++++++--- components/input/input.md | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/components/input/index.cjsx b/components/input/index.cjsx index 776784fee..0b58f0c71 100644 --- a/components/input/index.cjsx +++ b/components/input/index.cjsx @@ -88,11 +88,17 @@ module.exports = React.createClass # -- Extends + blur: -> + @refs.input.blur?() + + focus: -> + @refs.input.focus?() + getValue: -> @refs.input?.getDOMNode()[if @state.touch then 'checked' else 'value'] - setValue: (data) -> - @setState value: data - setError: (data = 'Unknown error') -> @setState error: @props.error or data + + setValue: (data) -> + @setState value: data diff --git a/components/input/input.md b/components/input/input.md index a8b63130b..955131575 100644 --- a/components/input/input.md +++ b/components/input/input.md @@ -27,6 +27,22 @@ var Input = require('react-toolbox/components/input'); ## Methods +#### focus +The focus event is sent to an element when it gains focus. + +``` +input_instance.focus(); +``` + + +#### blur +The blur event is sent to an element when it loses focus + +``` +input_instance.blur(); +``` + + #### getValue Returns the value of the input.