I have multiple connectedSortable
sections, each div has one div.widget
inside of it, as following :
<div class="row">
<section class="col-xs-4 col-sm-4 col-md-4 col-lg-4 connectedSortable">
<div class="widget">Widget 1</div>
</section>
<section class="col-xs-4 col-sm-4 col-md-4 col-lg-4 connectedSortable">
<div class="widget">Widget 2</div>
</section>
<section class="col-xs-4 col-sm-4 col-md-4 col-lg-4 connectedSortable">
<div class="widget">Widget 3</div>
</section>
</div>
<div class="row">
<section class="col-xs-3 col-sm-3 col-md-3 col-lg-3 connectedSortable">
<div class="widget">Widget 4</div>
</section>
<section class="col-xs-3 col-sm-3 col-md-3 col-lg-3 connectedSortable">
<div class="widget">Widget 5</div>
</section>
<section class="col-xs-3 col-sm-3 col-md-3 col-lg-3 connectedSortable">
<div class="widget">Widget 6</div>
</section>
<section class="col-xs-3 col-sm-3 col-md-3 col-lg-3 connectedSortable">
<div class="widget">Widget 7</div>
</section>
</div>
Using the sortable jQuery plugin, it will insert the dragged div into connectedSortable
section instead of swapping.
What I want to do is instead of inserting that div inside connectedSortable
section, I want to swap it with the div which is inside that connectedSortable
section.
And when a connectedSortable
section has no div.widget
inside of it, I can drop only one div.widget
and nothing to be swapped since it's already empty.
How can I do that ?
This is a jsfiddle of what I tried : http://jsfiddle.net/pus4aff6/