Projekt

Obecné

Profil

Stáhnout (993 Bajtů) Statistiky
| Větev: | Revize:
1
$(document).ready(function(){
2
    // set up sorting
3
    $(".sort").sortable().disableSelection();
4

    
5
    // action after press button "Uložit řazení"
6
    $('#saveSort').on('click', function () {
7

    
8
        // load csfr tokens
9
        var token = $('#_csrf').attr('content');
10
        var header = $('#_csrf_header').attr('content');
11

    
12
        // load values from table
13
        var orderArray = $('.sort').sortable('toArray');
14

    
15
        if (orderArray.length > 0)
16
        {
17
            // make ajax request to save new order
18
            $.ajax({
19
                type: "POST",
20
                url: "/saveOrder",
21
                data: orderArray.toString(),
22
                dataType: "text",
23
                contentType: "text/plain;charset=UTF-8",
24
                beforeSend: function(xhr) {
25
                    xhr.setRequestHeader(header, token);
26
                },
27
                success: function (data) {
28
                    alert(data);
29
                }
30
            });
31
        }
32

    
33
    })
34
});
(14-14/15)