Show message of success when dragging component with jQuery UI

0

I have the following jQuery:

$(function() {
    $( "#sortable1, #sortable2, #sortable3, #sortable4, #sortable5, #sortable6").sortable({
        connectWith: ".connectedSortable"
    }).disableSelection();
});

This jQuery drags one div into another so far, okay! I want you to drag and% success by dragging and dropping%.

How can I do this?

    
asked by anonymous 24.08.2016 / 15:47

1 answer

2

The plugin api is always a good reference, in your case specifically in the events part.

For this, it depends a little on the context, it has 3 events, stop() , update() and receive() .

The stop() is fired whenever you, of course, stop dragging the element.

While update() is very similar, but fires only if there is a change of position.

The% w / w that I think is the right one for you, is triggered when you drop an element from another list connected to the source list.

The code is very simple:

$(function() {
    $("#sortable1, #sortable2, #sortable3, #sortable4, #sortable5, #sortable6").sortable({
        connectWith: ".connectedSortable",
        update: function (event, ui) {
            alert('Arrastado com sucesso com alteração.')
        },
        stop: function(event, ui) {
            alert('Arrastado com sucesso, mesma posição.')
        },
        receive: function(event, ui) {
            alert('Arrastado com sucesso para outra lista.')
        },
    }).disableSelection();
});

Now just decide which is best for you.

    
24.08.2016 / 16:17