1 |
9037608d
|
cagy
|
$(document).ready(function(){
|
2 |
d149244c
|
cagy
|
|
3 |
|
|
// test if button for save order exists
|
4 |
|
|
if ($('#saveSort').length < 1)
|
5 |
|
|
{
|
6 |
|
|
return;
|
7 |
|
|
}
|
8 |
|
|
|
9 |
9037608d
|
cagy
|
// set up sorting
|
10 |
|
|
$(".sort").sortable().disableSelection();
|
11 |
|
|
|
12 |
|
|
// action after press button "Uložit řazení"
|
13 |
|
|
$('#saveSort').on('click', function () {
|
14 |
|
|
|
15 |
|
|
// load csfr tokens
|
16 |
|
|
var token = $('#_csrf').attr('content');
|
17 |
|
|
var header = $('#_csrf_header').attr('content');
|
18 |
|
|
|
19 |
|
|
// load values from table
|
20 |
|
|
var orderArray = $('.sort').sortable('toArray');
|
21 |
|
|
|
22 |
|
|
if (orderArray.length > 0)
|
23 |
|
|
{
|
24 |
|
|
// make ajax request to save new order
|
25 |
|
|
$.ajax({
|
26 |
|
|
type: "POST",
|
27 |
|
|
url: "/saveOrder",
|
28 |
|
|
data: orderArray.toString(),
|
29 |
|
|
dataType: "text",
|
30 |
|
|
contentType: "text/plain;charset=UTF-8",
|
31 |
|
|
beforeSend: function(xhr) {
|
32 |
|
|
xhr.setRequestHeader(header, token);
|
33 |
|
|
},
|
34 |
|
|
success: function (data) {
|
35 |
|
|
alert(data);
|
36 |
|
|
}
|
37 |
|
|
});
|
38 |
|
|
}
|
39 |
b3c57a7c
|
cagy
|
});
|
40 |
9037608d
|
cagy
|
});
|