I have a list with z-indexes set in reverse order:
<ul>
<li style="z-index: 3;">First item</li>
<li style="z-index: 2;">Second item</li>
<li style="z-index: 1;">Third item</li>
</ul>
With jQuery UI sortable I want to achieve the effect when z-indexes of my elements don't change when I sort the items. Say, I want to sort all represented items in this order: Second, Third, First. But leave z-indexes untouched!
Thanks.
This is what I've achieved with JS so far (I'm all new in this):
$('#widget-2').sortable({
start: function(event, ui) {
ui.item.data('originIndex', ui.item.css('z-index'));
},
change: function(event, ui) {
ui.item.data('placeholderIndex', ui.placeholder.css('z-index'));
var originIndex = ui.item.data('originIndex');
var placeholderIndex = ui.item.data('placeholderIndex');
ui.placeholder.css('z-index', originIndex);
ui.item.css('z-index', placeholderIndex);
}
});