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.11.6 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.11.5 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.11.2 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.11.1 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.11.0 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.10.7 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.10.6 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.10.5 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.10.4 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.10.3 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.10.2 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.10.1 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.10.0 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.9.2 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.9.1 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.9.0 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.8.6 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.8.5 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.8.4 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx
revelry_core-0.1.8.3 app/assets/javascripts/revelry/ui/forms/CollectionSelectBox.js.cjsx