I am using bootstrap with jQuery UI to create drag and drop feature for my lists.
My HTML is:
<ul class="draggablePanelList list-unstyled">
<li class="panel panel-info">
<div class="panel-heading">You can drag this panel.</div>
<div class="panel-body">Content ...</div>
</li>
<li class="panel panel-info">
<div class="panel-heading">You can drag this panel too.</div>
<div class="panel-body">Content ...</div>
</li>
</ul>
My script which makes the drag and drop feature work:
jQuery(function($) {
var panelList = $('.draggablePanelList');
panelList.sortable({
// Only make the .panel-heading child elements support dragging.
// Omit this to make then entire <li>...</li> draggable.
update: function() {
$('.panel', panelList).each(function(index, elem) {
var $listItem = $(elem),
newIndex = $listItem.index();
// Persist the new indices.
});
}
});
});
I want to add javascript which indicates which item was dragged and dropped and where it is now in the list (using a element attribute to track). How can I do that.
Thanks