Sha256: 4509e76d6b6604412e08fb5350f4b6f69c994695948206fcc7decf89784fd258
Contents?: true
Size: 1004 Bytes
Versions: 12
Compression:
Stored size: 1004 Bytes
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: @value() name: @name() if @props.type == 'textarea' t = 'textarea' if @isCheckbox() form_params['defaultChecked'] = @value() <Rev.Components.Input dom={t} {...form_params} {...@props} onChange={ @onChange } error={ @state.error } onBlur={ @onBlur } /> 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
12 entries across 12 versions & 1 rubygems