ItzMe_Ezhil
ItzMe_Ezhil

Reputation: 1406

Jquery UI - Sortable between the Div not Within Div

REF Image

I have 'N' number of start row (red border) I want sortable(number box 1, 2, 3 etc..) form start row(red border) to receive row(green border).

sortable should not work within start row (red border). And sortable within the receive row (green border) must work.

Note: Here i want to only disable/ cancel sortable function within the start row(red border). Below script code used.

    $('.draggable-row').sortable({
     connectWith:".sortable-row"

         });

     $('.sortable-row').sortable({
     connectWith:".sortable-row"

     });

Demo

Upvotes: 2

Views: 839

Answers (1)

Runcorn
Runcorn

Reputation: 5224

You can use beforeStop event of Sortable ,

 beforeStop: function (event, ui) {
        //$(ui.placeholder).parent()[0] gives target sort element
        //If this is current element revert sort
        if ($(ui.placeholder).parent()[0] == this) {
            $(this).sortable('cancel');
        }
    }

See the working Fiddle

I hope this will help you .

Upvotes: 1

Related Questions