Sha256: 52b3c15c279e0c1e204a25c84b02fc459dd66385eecab5266b8dd636b8bed45b
Contents?: true
Size: 830 Bytes
Versions: 10
Compression:
Stored size: 830 Bytes
Contents
window.Alchemy = {} if typeof(window.Alchemy) is 'undefined' Alchemy.Autocomplete = tags: (scope) -> field = $('[data-autocomplete]', scope) url = field.data('autocomplete') field.select2 tags: true tokenSeparators: [","] minimumInputLength: 1 openOnEnter: false createSearchChoice: @_createResultItem ajax: url: url dataType: 'json' data: (term, page) -> term: term results: (data, page) -> results: data initSelection: @_initializeSelection _createResultItem: (term, data) -> if $(data).filter(-> @text.localeCompare(term) is 0).length is 0 id: term text: term _initializeSelection: (element, callback) -> data = [] $(element.val().split(",")).each -> data.push id: this, text: this callback(data)
Version data entries
10 entries across 10 versions & 1 rubygems