Sha256: ebd026a3a9e043c87f39cdb667724440e1da307723ba8d1567b2da7708981329

Contents?: true

Size: 1.19 KB

Versions: 10

Compression:

Stored size: 1.19 KB

Contents

'use strict';

var set_taxon_select = function(){
  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,
            without_children: true,
            q: {
              name_cont: term
            }
          };
        },
        results: function (data, page) {
          var more = page < data.pages;
          return {
            results: data['taxons'],
            more: more
          };
        }
      },
      formatResult: function (taxon) {
        return taxon.pretty_name;
      },
      formatSelection: function (taxon) {
        return taxon.pretty_name;
      }
    });
  }
}

$(document).ready(function () {
  set_taxon_select()
});

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
spree_backend-3.0.0.rc3 app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb
spree_backend-2.4.4 app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb
spree_backend-3.0.0.rc1 app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb
spree_backend-2.4.3 app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb
spree_backend-2.4.2 app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb
spree_backend-2.4.1 app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb
spree_backend-2.4.0 app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb
spree_backend-2.4.0.rc3 app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb
spree_backend-2.4.0.rc2 app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb
spree_backend-2.4.0.rc1 app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb