Sha256: 786b2360433301921a6668572d7c47f2a4daf7de9437da7f73a72b61f77e5798
Contents?: true
Size: 1.93 KB
Versions: 4
Compression:
Stored size: 1.93 KB
Contents
# ----------------------------------------------------------------------------- # Author: Alexander Kravets <alex@slatestudio.com>, # Slate Studio (http://www.slatestudio.com) # ----------------------------------------------------------------------------- # INPUT SELECT # ----------------------------------------------------------------------------- class @InputSelect extends InputString # PRIVATE =================================================================== _create_el: -> @$el =$ "<div class='form-input input-#{ @config.type } input-#{ @config.klassName }'>" _add_input: -> @$input =$ """<select name='#{ @name }'></select>""" @$el.append @$input @_add_options() _add_options: -> if @config.optionsHashFieldName @value = String(@value) if @object @config.optionsHash = @object[@config.optionsHashFieldName] else @config.optionsHash = { '': '--' } if @config.collection @_add_collection_options() else if @config.optionsList @_add_list_options() else if @config.optionsHash @_add_hash_options() _add_collection_options: -> for o in @config.collection.data title = o[@config.collection.titleField] value = o[@config.collection.valueField] @_add_option(title, value) _add_list_options: -> data = @config.optionsList for o in data @_add_option(o, o) _add_hash_options: -> data = @config.optionsHash for value, title of data @_add_option(title, value) _add_option: (title, value) -> selected = if @value == value then 'selected' else '' $option =$ """<option value='#{ value }' #{ selected }>#{ title }</option>""" @$input.append $option # PUBLIC ==================================================================== updateValue: (@value, @object) -> @$input.html('') @_add_options() @$input.val(@value).prop('selected', true) chr.formInputs['select'] = InputSelect
Version data entries
4 entries across 4 versions & 1 rubygems