Sha256: f026f98d6cd6f7315304ed0d181e73c5fc7e996316675d7d358e1b22568e5bd4
Contents?: true
Size: 1.56 KB
Versions: 4
Compression:
Stored size: 1.56 KB
Contents
# ----------------------------------------------------------------------------- # Author: Alexander Kravets <alex@slatestudio.com>, # Slate Studio (http://www.slatestudio.com) # ----------------------------------------------------------------------------- # INPUT LIST TYPEAHEAD # ----------------------------------------------------------------------------- @inputListTypeahead = # PRIVATE =================================================================== _create_typeahead_el: (placeholder) -> # typeahead input for adding new items @typeaheadInput =$ "<input type='text' placeholder='#{ placeholder }' />" @$el.append @typeaheadInput _bind_typeahead: -> limit = @config.typeahead.limit || 5 dataSource = new Bloodhound datumTokenizer: Bloodhound.tokenizers.obj.whitespace(@config.titleFieldName) queryTokenizer: Bloodhound.tokenizers.whitespace remote: url: @config.typeahead.url # exclude objects that are already in the list filter: (parsedResponse) => data = [] for o in parsedResponse @_normalize_object(o) ; if ! @objects[o._id] then data.push(o) return data limit: limit dataSource.initialize() @typeaheadInput.typeahead({ hint: false highlight: true }, { name: @config.klassName displayKey: @config.titleFieldName source: dataSource.ttAdapter() }) @typeaheadInput.on 'typeahead:selected', (e, object, dataset) => @_render_item(object) @typeaheadInput.typeahead('val', '')
Version data entries
4 entries across 4 versions & 1 rubygems