Sha256: f85dc76b64fb8501d7ab4efc5e38beb38974d32c10ca88d3fe95d3c8f0c0e2b9
Contents?: true
Size: 1.09 KB
Versions: 32
Compression:
Stored size: 1.09 KB
Contents
Rev.registerComponent 'ModelInput', mixins: [ Rev.App.Mixins.ModelInputMixin, Backbone.Events ] propTypes: field: React.PropTypes.string.isRequired model: React.PropTypes.object.isRequired name: React.PropTypes.string baseName: React.PropTypes.string getInitialState: -> error: null render: -> form_params = defaultValue: @defaultValue() name: @name() if @props.type in ['textarea', 'select'] t = @props.type if @isCheckbox() form_params['defaultChecked'] = @value() <Rev.Components.Input key="#{ @props.model.cid }-#{ @name() }" dom={t} {...form_params} {...@props} onChange={ @onChange } error={ @state.error } onBlur={ @onBlur }> { @props.children } </Rev.Components.Input> componentDidMount: -> @listenTo @props.model, 'error', @onError componentDidUnmount: -> @stopListening() onError: (model, resp, options)-> errors = resp.responseJSON.errors if errors && errors[@props.field] @setState error: errors[@props.field].join ' and ' onChange: (e)-> @setState error: null @onFieldChange(e)
Version data entries
32 entries across 32 versions & 1 rubygems