Skip to content

Commit 12a8731

Browse files
committed
fix: caricamento tabelle senza ordinamento
1 parent bb04d0d commit 12a8731

1 file changed

Lines changed: 19 additions & 15 deletions

File tree

assets/src/js/functions/init.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,26 @@ function init() {
107107

108108
restart_inputs();
109109

110-
sortable(".sortable", {
111-
axis: "y",
112-
handle: ".handle",
113-
cursor: "move",
114-
dropOnEmpty: true,
115-
scroll: true,
116-
})[0].addEventListener("sortupdate", function(e) {
117-
let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id"))
118-
119-
$.post(globals.rootdir + "/actions.php", {
120-
id_module: globals.id_module,
121-
id_record: globals.id_record,
122-
op: "update_position",
123-
order: order.join(","),
110+
const sortableElement = sortable(".sortable", {
111+
axis: "y",
112+
handle: ".handle",
113+
cursor: "move",
114+
dropOnEmpty: true,
115+
scroll: true,
116+
})[0];
117+
118+
if (sortableElement) {
119+
sortableElement.addEventListener("sortupdate", function(e) {
120+
let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id"))
121+
122+
$.post(globals.rootdir + "/actions.php", {
123+
id_module: globals.id_module,
124+
id_record: globals.id_record,
125+
op: "update_position",
126+
order: order.join(","),
127+
});
124128
});
125-
});
129+
}
126130
}
127131

128132
/**

0 commit comments

Comments
 (0)