Sha256: 67695e426987218e49e41d1ccc3d77dffa3c1f0f83eb436ec67703f41ac03537

Contents?: true

Size: 883 Bytes

Versions: 20

Compression:

Stored size: 883 Bytes

Contents

$.fn.userAutocomplete = function () {
  'use strict';

  this.select2({
    minimumInputLength: 1,
    multiple: true,
    initSelection: function (element, callback) {
      $.get(Spree.routes.user_search, {
        ids: element.val()
      }, function (data) {
        callback(data);
      });
    },
    ajax: {
      url: Spree.routes.user_search,
      datatype: 'json',
      params: { "headers": { "X-Spree-Token": Spree.api_key } },
      data: function (term) {
        return {
          q: term,
          token: Spree.api_key
        };
      },
      results: function (data) {
        return {
          results: data
        };
      }
    },
    formatResult: function (user) {
      return user.email;
    },
    formatSelection: function (user) {
      return user.email;
    }
  });
};

$(document).ready(function () {
  $('.user_picker').userAutocomplete();
});

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
solidus_backend-1.2.0 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.2.0.rc2 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.0.4 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.1.2 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.2.0.rc1 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.2.0.beta1 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.0.3 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.1.1 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.1.0 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.1.0.pre2 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.1.0.pre1 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.1.0.beta1 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.0.2 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.0.1 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.0.0 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.0.0.rc2 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.0.0.rc1 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.0.0.pre3 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.0.0.pre2 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.0.0.pre app/assets/javascripts/spree/backend/user_picker.js