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:
parent
4379e49629
commit
b766e82e4b
1 changed files with 6 additions and 2 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue