is there a way to make Jquery ui sortable have it's item index count from bottom instead of from top?
For example:
<ul id="sortable">
<li>Item 1</li> // ui.item.index() = 0
<li>Item 2</li> // ui.item.index() = 1
<li>Item 3</li> // ui.item.index() = 2
<li>Item 4</li> // ui.item.index() = 3
</ul>
And have it like this:
<ul id="sortable">
<li>Item 1</li> // ui.item.index() = 3
<li>Item 2</li> // ui.item.index() = 2
<li>Item 3</li> // ui.item.index() = 1
<li>Item 4</li> // ui.item.index() = 0
</ul>
I'm trying to set the z-index from div.Zindex
where it's z-index: (ui.item.index()*10)
:
$( "#sortable" ).sortable({
stop: function(event, ui) {
$( "#sortable li" ).map( function(){
var updateZindex = 0;
if($(this).index() == 0){
updateZindex = 1000;
}else{
updateZindex = $(this).index()*10;
}
$('#parent').find('div[id='+$(this).attr('id')+']').css('z-index', updateZindex);
});
}
});
$( "#sortable" ).disableSelection();
Thank you