0

Firstly, I need to send attribute data-name with sorting like this:

/sorting?firstname=0&lastname=1&email=2&country=3

Here is my code:

$("#sortable").sortable({
    revert: true,
    axis: 'y',
    stop: function(event, ui) {
        var data = $(this).sortable('toArray', {
            attribute: 'data-name'
        });
        $.ajax({
            data: data,
            type: 'GET',
            url: '/sorting'
        });
    }
});
$("#draggable").draggable({
    connectToSortable: "#sortable",
    helper: "clone",
    revert: "invalid"
});

How to do that?

And secondly, when i dragged item "Drag empty" to the list, I need to send sorting without them. I need to skip them, for. ex.:

/sorting?firstname=0&lastname=1&email=3&country=4

"Drag empty" is after lastname, then email and country have sorting +1.

Here code sample:

https://jsfiddle.net/3b95e27p/

Milap
  • 6,915
  • 8
  • 26
  • 46
Haroldas
  • 964
  • 3
  • 9
  • 36
  • Possible duplicate of [Convert Array to Object](http://stackoverflow.com/questions/4215737/convert-array-to-object) Same conversion for this question, just invert the places of the idx and value: https://jsfiddle.net/dxa7asza/ – blgt Feb 19 '16 at 09:51
  • Why not use the inbuilt serialize option and update your backend accordingly...? – T J Feb 20 '16 at 05:31

0 Answers0