Sha256: 1173d01ae22c8012b47590dba3250804483aa2aa433f863d2a5552026920a33c

Contents?: true

Size: 1.11 KB

Versions: 57

Compression:

Stored size: 1.11 KB

Contents

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

  function formatOptionType (optionType) {
    return Select2.util.escapeMarkup(optionType.presentation + ' (' + optionType.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_types_api, {
          ids: element.val(),
          token: Spree.api_key
        })
        return $.getJSON(url, null, function (data) {
          return callback(data)
        })
      },
      ajax: {
        url: Spree.routes.option_types_api,
        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

57 entries across 57 versions & 1 rubygems

Version Path
spree_backend-4.0.9 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-4.1.15 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-4.1.14 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-4.0.8 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.7.14.1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-4.1.13.1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-4.0.7.1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-4.0.7 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.7.14 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-4.1.13 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-4.0.6 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-4.2.0.rc2 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.7.13 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-4.0.5 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-4.1.12 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.7.12 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-4.2.0.rc1 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-4.0.4 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-3.7.11 app/assets/javascripts/spree/backend/option_type_autocomplete.js
spree_backend-4.1.11 app/assets/javascripts/spree/backend/option_type_autocomplete.js