Sha256: a83f870b5cac9b315e0eb48f1ecb5a54789f75e796d583cc932f114108762e60

Contents?: true

Size: 1.13 KB

Versions: 23

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) {
        var url = Spree.url(Spree.routes.option_type_search, {
          ids: element.val(),
          token: Spree.api_key
        });
        return $.getJSON(url, null, function (data) {
          return callback(data);
        });
      },
      ajax: {
        url: Spree.routes.option_type_search,
        quietMillis: 200,
        datatype: 'json',
        data: function (term) {
          return {
            q: {
              name_cont: term
            },
            token: Spree.api_key
          };
        },
        results: function (data) {
          return {
            results: data
          };
        }
      },
      formatResult: formatOptionType,
      formatSelection: formatOptionType
    });
  }
});

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
spree_backend-3.1.14 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.13 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.12 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.11 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.10 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.9 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.8 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.7 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.6 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.5 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.4 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.3 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.2 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.0.10 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.0 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.0.rc4 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.0.9 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.0.rc3 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.1.0.rc2 app/assets/javascripts/spree/backend/option_type_autocomplete.js