Sha256: 31be20ce618832c2c671f1b0027626ee03582b7db82ff45ad8e5fe3eabfc4d6c
Contents?: true
Size: 1.01 KB
Versions: 12
Compression:
Stored size: 1.01 KB
Contents
document.addEventListener("spree:load", function() { var parentEl = document.getElementsByClassName('sortable')[0]; if (parentEl) { var element = parentEl.querySelector('tbody') } if (element) { Sortable.create(element, { handle: '.move-handle', animation: 550, ghostClass: 'bg-light', dragClass: 'sortable-drag-v', easing: 'cubic-bezier(1, 0, 0, 1)', swapThreshold: 0.9, forceFallback: true, onEnd: function(evt) { var itemEl = evt.item var positions = { authenticity_token: AUTH_TOKEN } $.each($('tr', element), function(position, obj) { var reg = /spree_(\w+_?)+_(.*)/ var parts = reg.exec($(obj).prop('id')) if (parts) { positions['positions[' + parts[2] + ']'] = position + 1 } }) $.ajax({ type: 'POST', dataType: 'json', url: $(itemEl).closest('table.sortable').data('sortable-link'), data: positions }) } }) } })
Version data entries
12 entries across 12 versions & 1 rubygems