Sha256: 4f900e58e530d9501acba3e2bec395d765def3e07a4211e560301141be82549a

Contents?: true

Size: 877 Bytes

Versions: 40

Compression:

Stored size: 877 Bytes

Contents

#= require underscore
#= require backbone

Rev.registerComponent 'CollectionSelectBox',

  getDefaultProps: ->
    props =
      collection: new Backbone.Collection()
      modelToKey: (model) -> model.id
      modelToValue: (model) -> model.id
      modelToChildContent: (model) -> model.id
      onChange: (e) -> return
      selectBoxClassName: "RevCollectionSelectBox"
      optionClassName: "RevCollectionSelectBox-option"

  onChange: (e) ->
    e.model = @props.collection.get e.currentTarget.value
    @props.onChange(e)

  render: ->
    @transferPropsTo <select className={@props.selectBoxClassName} onChange={@onChange}>
      { @props.collection.map => @renderOption.apply this, arguments }
    </select>

  renderOption: (model) ->
    <option key={@props.modelToKey model} value={@props.modelToValue model}>
      {@props.modelToChildContent model}
    </option>

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
revelry_core-0.1.8.2 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.8.1 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.8.0 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.7.0 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.6.8 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.6.7 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.6.6 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.6.5 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.6.4 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.6.3 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.6.2 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.6.1 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.5 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.4 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.3 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.2 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.1 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.0 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.0.1 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.0.0 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx