Sha256: 94db2cc600ab1cd877d3a112c2b61d3d845fefef4b57b333dabfb895f362ae44

Contents?: true

Size: 1.14 KB

Versions: 21

Compression:

Stored size: 1.14 KB

Contents

Spree.ready(function () {
  'use strict';

  function formatOptionType(option_type) {
    return Select2.util.escapeMarkup(option_type.presentation + ' (' + option_type.name + ')');
  }

  if ($('#product_option_type_ids').length > 0) {
    $('#product_option_type_ids').select2({
      placeholder: Spree.translations.option_type_placeholder,
      multiple: true,
      initSelection: function (element, callback) {
        return Spree.ajax({
          url: Spree.routes.option_type_search,
          data: { ids: element.val() },
          type: 'get',
          success: function(data) {
            return callback(data);
          }
        });
      },
      ajax: {
        url: Spree.routes.option_type_search,
        quietMillis: 200,
        datatype: 'json',
        params: { "headers": {  'Authorization': 'Bearer ' + Spree.api_key } },
        data: function (term) {
          return {
            q: { name_cont: term }
          };
        },
        results: function (data) {
          return {
            results: data
          };
        }
      },
      formatResult: formatOptionType,
      formatSelection: formatOptionType
    });
  }
});

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
solidus_backend-2.10.5 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.10.3 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.10.2 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.9.6 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.8.6 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.10.1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.9.5 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.10.0 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.9.4 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.8.5 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.9.3 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.9.2 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.10.0.beta1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.9.1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.9.0 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.9.0.rc.1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.8.4 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.8.3 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.8.2 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.8.1 app/assets/javascripts/spree/backend/option_type_autocomplete.js