Sha256: 64c9c2d6225bdb20b8a804960c86a9d2ad1a7a814c6e385520da3f049eeaf94a
Contents?: true
Size: 1019 Bytes
Versions: 29
Compression:
Stored size: 1019 Bytes
Contents
//= require solidus_admin/Sortable /* eslint no-unused-vars: "off" */ Spree.SortableTable = { refresh: 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); if (!isNaN(objId)) { positions['positions['+objId+']'] = index + 1; } } }); Spree.ajax({ type: 'POST', dataType: 'json', url: url, data: positions, }); } }); }); } }; Spree.ready(Spree.SortableTable.refresh);
Version data entries
29 entries across 29 versions & 1 rubygems