I am using jquery-ui sortable and I've got one sortable inside other! Point is when I'm trying to work with sortstop function, parent sortable runs as well(! Help me please!
<div class="sortable1">
<div class="s1">
<div class="sortable2">
<div class="s2"></div>
<div class="s2"></div>
<div class="s2"></div>
<div class="s2"></div>
</div>
</div>
<div class="s1"></div>
<div class="s1"></div>
<div class="s1"></div>
<div class="s1"></div>
JS:
//parents
$( ".sortable1" ).sortable({
items: ".s1"
});
$( ".sortable1" ).disableSelection();
$( ".sortable1" ).on( "sortstop", function( event, ui ){
//do sort of parents
});
//children
$( ".sortable2" ).sortable({
items: ".s2"
});
$( ".sortable2" ).disableSelection();
$( ".sortable2" ).on( "sortstop", function( event, ui ){
//do sort of childrens
});
I have created a DEMO here
To identify whether the
parentorchildsortable element was moved, you can use the below code onsortstopevent of theparentHere is the complete code from the DEMO:
HTML:
JS: