Sha256: c71c3580a42ff3cff3c45bff7d9c517141cf3a2127fe95546adec373bffcf1ce

Contents?: true

Size: 849 Bytes

Versions: 14

Compression:

Stored size: 849 Bytes

Contents

//= require solidus_admin/Sortable
/* eslint no-unused-vars: "off" */

Spree.ready(function() {
  var sortable_tables = document.querySelectorAll('table.sortable');

  _.each(sortable_tables, function(table) {
    var url = table.getAttribute('data-sortable-link');
    var tbody = table.querySelector('tbody');
    var sortable = Sortable.create(tbody,{
      handle: ".handle",
      onEnd: function(e) {
        var positions = {};
        _.each(e.to.querySelectorAll('tr'), function(el, index) {
          var idAttr = el.id;
          if (idAttr) {
            var objId = idAttr.split('_').slice(-1);
            positions['positions['+objId+']'] = index + 1;
          }
        });
        Spree.ajax({
          type: 'POST',
          dataType: 'json',
          url: url,
          data: positions,
        });
      }
    });
  });
});

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
solidus_backend-2.10.5 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.10.3 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.10.2 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.9.6 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.10.1 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.9.5 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.10.0 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.9.4 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.9.3 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.9.2 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.10.0.beta1 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.9.1 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.9.0 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.9.0.rc.1 app/assets/javascripts/spree/backend/components/sortable_table.js