Sha256: 5f8ded1d56f44bc1e8aa9b1370fd2ace119ba4e365a22acb846e9e2ab54a39df

Contents?: true

Size: 814 Bytes

Versions: 39

Compression:

Stored size: 814 Bytes

Contents

//= require solidus_admin/Sortable

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

39 entries across 39 versions & 2 rubygems

Version Path
solidus_backend-2.8.6 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.6.6 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.7.4 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.8.5 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.7.3 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.6.5 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.5.2 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.8.4 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.8.3 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.7.2 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.6.4 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.8.2 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.8.1 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.5.1 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.6.3 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.8.0 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.7.1 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend-2.6.2 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend_devise_token_auth-2.8.0.alpha.14 app/assets/javascripts/spree/backend/components/sortable_table.js
solidus_backend_devise_token_auth-2.8.0.alpha.13 app/assets/javascripts/spree/backend/components/sortable_table.js