5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 07:21:43 +00:00

no intentar ordenar tablas que no existen

This commit is contained in:
f 2018-05-02 15:18:05 -03:00
parent 4379e49629
commit b766e82e4b
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7

View file

@ -1,7 +1,11 @@
$(document).on('turbolinks:load', function() {
var table = document.querySelector('.table-draggable');
if (table == null) return;
var were = $('.order.was').map(function() { return $(this).data('order') });
tableDragger(document.querySelector('.table-draggable'), {
tableDragger(table, {
mode: 'row',
onlyBody: true,
dragHandler: '.handle'
@ -9,7 +13,7 @@ $(document).on('turbolinks:load', function() {
// Al soltar, reordenamos toda la tabla
$('.post_order').val(function(i,v) { return were[i]; });
// Mostramos el nuevo orden también
$('.order.is').text(function(i,v) { console.log(i, were[i]); return were[i]; });
$('.order.is').text(function(i,v) { return were[i]; });
// Solo mostramos el valor anterior si no coincide con el valor
// actual. Como lo mostramos entre comillas, usamos el atributo
// data-order del <span>