Sha256: 6ac9c62294e3cbbccb3e0e9882e5d880737a451821e8995b5c994a60b2583006
Contents?: true
Size: 1.1 KB
Versions: 31
Compression:
Stored size: 1.1 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": { "X-Spree-Token": 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 }); }; $(document).ready(function () { $('.user_picker').userAutocomplete(); });
Version data entries
31 entries across 31 versions & 1 rubygems