Sha256: 5d2819bbcb2d86eeeff904bf56dd366b5c825149e97495ba268d3bb72c3f08ae

Contents?: true

Size: 1.13 KB

Versions: 45

Compression:

Stored size: 1.13 KB

Contents

$(document).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": { "X-Spree-Token": Spree.api_key } },
        data: function (term) {
          return {
            q: { name_cont: term }
          };
        },
        results: function (data) {
          return {
            results: data
          };
        }
      },
      formatResult: formatOptionType,
      formatSelection: formatOptionType
    });
  }
});

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
solidus_backend-2.4.2 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.4.1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.3.1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.2.2 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.1.1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.0.3 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-1.4.2 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-1.3.2 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-1.2.3 app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb
solidus_backend-1.1.4 app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb
solidus_backend-1.0.7 app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb
solidus_backend-2.4.0 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.4.0.rc1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.4.0.beta1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.3.0 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.3.0.rc3 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.3.0.rc2 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.3.0.rc1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.3.0.beta1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend-2.0.2 app/assets/javascripts/spree/backend/option_type_autocomplete.js