Sha256: 461c45d7da0d13f6b379733bf7e45805aa51dff9fb1389180469f8f18dc3a4e7
Contents?: true
Size: 1.11 KB
Versions: 21
Compression:
Stored size: 1.11 KB
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) { Spree.ajax({ url: Spree.routes.users_api, data: { ids: element.val() }, success: function(data) { callback(data.users); } }); }, ajax: { url: Spree.routes.users_api, datatype: 'json', params: { "headers": { 'Authorization': 'Bearer ' + Spree.api_key } }, data: function (term) { return { q: { m: 'or', email_start: term, addresses_firstname_start: term, addresses_lastname_start: term } }; }, results: function (data) { return { results: data.users, more: data.current_page < data.pages }; } }, formatResult: formatUser, formatSelection: formatUser }); }; Spree.ready(function () { $('.user_picker').userAutocomplete(); });
Version data entries
21 entries across 21 versions & 1 rubygems