Sha256: 40f3293b3488f9236e5f8d9f64cf7b283ae22ba90a74eeedb683cda4d063c5b9

Contents?: true

Size: 1.16 KB

Versions: 18

Compression:

Stored size: 1.16 KB

Contents

$(document).ready(function () {
  'use strict';

  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: function (option_type) {
        return option_type.presentation + ' (' + option_type.name + ')';
      },
      formatSelection: function (option_type) {
        return option_type.presentation + ' (' + option_type.name + ')';
      }
    });
  }
});

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
spree_backend-3.0.6.1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.0.6 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.0.5 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.0.4 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-2.4.10 app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb
spree_backend-2.3.13 app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb
spree_backend-3.0.3 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-2.4.9 app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb
spree_backend-2.3.12 app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb
spree_backend-3.0.2 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-2.4.8 app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb
spree_backend-2.3.11 app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb
spree_backend-3.0.1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-2.4.7 app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb
spree_backend-2.3.10 app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb
spree_backend-3.0.0 app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb
spree_backend-2.4.6 app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb
spree_backend-2.3.9 app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb