Sha256: e2268425f335b313aafb0452729734bdd049e829c93e8738f5c9cbc1b83cbcf0

Contents?: true

Size: 1.13 KB

Versions: 12

Compression:

Stored size: 1.13 KB

Contents

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

  if ($('#product_taxon_ids').length > 0) {
    $('#product_taxon_ids').select2({
      placeholder: Spree.translations.taxon_placeholder,
      multiple: true,
      initSelection: function (element, callback) {
        var url = Spree.url(Spree.routes.taxons_search, {
          ids: element.val()
        });
        return $.getJSON(url, null, function (data) {
          return callback(data['taxons']);
        });
      },
      ajax: {
        url: Spree.routes.taxons_search,
        datatype: 'json',
        data: function (term, page) {
          return {
            per_page: 50,
            page: page,
            q: {
              name_cont: term
            }
          };
        },
        results: function (data, page) {
          var more = page < data.pages;
          console.log(more)
          return {
            results: data['taxons'],
            more: more
          };
        }
      },
      formatResult: function (taxon) {
        return taxon.pretty_name;
      },
      formatSelection: function (taxon) {
        return taxon.pretty_name;
      }
    });
  }
});

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
spree_backend-2.0.13 app/assets/javascripts/admin/taxon_autocomplete.js.erb
spree_backend-2.0.12 app/assets/javascripts/admin/taxon_autocomplete.js.erb
spree_backend-2.0.11 app/assets/javascripts/admin/taxon_autocomplete.js.erb
spree_backend-2.0.10 app/assets/javascripts/admin/taxon_autocomplete.js.erb
spree_backend-2.0.9 app/assets/javascripts/admin/taxon_autocomplete.js.erb
spree_backend-2.0.8 app/assets/javascripts/admin/taxon_autocomplete.js.erb
spree_backend-2.0.7 app/assets/javascripts/admin/taxon_autocomplete.js.erb
spree_backend-2.1.2 app/assets/javascripts/admin/taxon_autocomplete.js.erb
spree_backend-2.0.6 app/assets/javascripts/admin/taxon_autocomplete.js.erb
spree_backend-2.1.1 app/assets/javascripts/admin/taxon_autocomplete.js.erb
spree_backend-2.0.5 app/assets/javascripts/admin/taxon_autocomplete.js.erb
spree_backend-2.1.0 app/assets/javascripts/admin/taxon_autocomplete.js.erb