Sha256: 3e045c13eb0dc1ea66c9f925256bbba9de477224548642b35e62d3cff5e09458
Contents?: true
Size: 906 Bytes
Versions: 3
Compression:
Stored size: 906 Bytes
Contents
$.fn.userAutocomplete = function () { 'use strict' function formatUser (user) { return Select2.util.escapeMarkup(user.email) } this.select2({ minimumInputLength: 1, multiple: true, initSelection: function (element, callback) { $.get(Spree.routes.users_api, { ids: element.val().split(','), token: Spree.api_key }, function (data) { callback(data.users) }) }, ajax: { url: Spree.routes.users_api, datatype: 'json', data: function (term) { return { q: { email_start: term }, token: Spree.api_key } }, results: function (data) { return { results: data.users } } }, formatResult: formatUser, formatSelection: formatUser }) } $(document).ready(function () { $('.user_picker').userAutocomplete() })
Version data entries
3 entries across 3 versions & 1 rubygems