Sha256: 3b64f35eeab077679a756e7d700248610b913c29747404e204f43e9a69b4ba92

Contents?: true

Size: 774 Bytes

Versions: 11

Compression:

Stored size: 774 Bytes

Contents

//= require alchemy/solidus/admin/select2_config

$.fn.alchemyTaxonSelect = function(options) {
  var config = Alchemy.Solidus.getSelect2Config(options)

  this.select2($.extend(true, config, {
    ajax: {
      data: function(term, page) {
        return {
          q: $.extend({
            name_cont: term
          }, options.query_params),
          page: page
        }
      },
      results: function(data, page) {
        return {
          results: data.taxons.map(function(taxon) {
            return {
              id: taxon.id,
              text: taxon.name
            }
          }),
          more: page * data.per_page < data.total_count
        }
      }
    },
    formatSelection: function(taxon) {
      return taxon.text || taxon.name
    }
  }))
}

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
alchemy-solidus-3.3.0 app/assets/javascripts/alchemy/solidus/admin/taxon_select.js
alchemy-solidus-3.2.2 app/assets/javascripts/alchemy/solidus/admin/taxon_select.js
alchemy-solidus-3.2.1 app/assets/javascripts/alchemy/solidus/admin/taxon_select.js
alchemy-solidus-3.2.0 app/assets/javascripts/alchemy/solidus/admin/taxon_select.js
alchemy-solidus-3.1.1 app/assets/javascripts/alchemy/solidus/admin/taxon_select.js
alchemy-solidus-3.1.0 app/assets/javascripts/alchemy/solidus/admin/taxon_select.js
alchemy-solidus-3.0.2 app/assets/javascripts/alchemy/solidus/admin/taxon_select.js
alchemy-solidus-3.0.1 app/assets/javascripts/alchemy/solidus/admin/taxon_select.js
alchemy-solidus-3.0.0 app/assets/javascripts/alchemy/solidus/admin/taxon_select.js
alchemy-solidus-2.5.1 app/assets/javascripts/alchemy/solidus/admin/taxon_select.js
alchemy-solidus-2.5.0 app/assets/javascripts/alchemy/solidus/admin/taxon_select.js