Sha256: 20bfe4ccd073632493da5b65341c35febe8dedb57dd740d13626a0e5b5a065ce

Contents?: true

Size: 1.06 KB

Versions: 13

Compression:

Stored size: 1.06 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',
        data: function (term) {
          return {
            q: { name_cont: term }
          };
        },
        results: function (data) {
          return {
            results: data
          };
        }
      },
      formatResult: formatOptionType,
      formatSelection: formatOptionType
    });
  }
});

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
solidus_backend_devise_token_auth-2.8.0.alpha.14 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend_devise_token_auth-2.8.0.alpha.13 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend_devise_token_auth-2.8.0.alpha.12 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend_devise_token_auth-2.8.0.alpha.11 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend_devise_token_auth-2.8.0.alpha.10 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend_devise_token_auth-2.8.0.alpha.9 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend_devise_token_auth-2.8.0.alpha.8 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend_devise_token_auth-2.8.0.alpha.7 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend_devise_token_auth-2.8.0.alpha.6 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend_devise_token_auth-2.8.0.alpha.5 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend_devise_token_auth-2.8.0.alpha.4 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend_devise_token_auth-2.8.0.alpha.3 app/assets/javascripts/spree/backend/option_type_autocomplete.js
solidus_backend_devise_token_auth-2.8.0.alpha.2 app/assets/javascripts/spree/backend/option_type_autocomplete.js