Reputation: 114
Here is my fiddle:
I would like for the numbers to increase/decrease based on the value/amount of items in the list. Thanks for the help/tips.
$(function () {
$("#sortable-primary").sortable({
placeholder: "ui-state-highlight",
connectWith: ".connected-sortable"
});
$("#sortable-secondary").sortable({
placeholder: "ui-state-highlight",
connectWith: ".connected-sortable"
});
$("#sortable-primary, #sortable-secondary").disableSelection();
});
Upvotes: 1
Views: 25
Reputation: 1451
I think you will need to put the items in one UL, this will certainly make it less complex. I didn't entirely clean up the CSS, but I think this will get you started. It is at least one solution.
function numberLi(){
var i = 1;
$('#sortable-primary > .ca-nav-move > .num').each(function(){
$(this).text(i);
i++;
});
$('#sortable-secondary > .ca-nav-move > .num').each(function(){
$(this).text("");
});
}
Here is an updated fiddle, that will remove the numbers from the bottom list when dragged there.
I didnt like the way that looked with the numbers being dragged along with the item, I decided I could do better. Here is a 3rd fiddle that performs exactly the way you wanted it to. Please mark this as the accepted answer.
Upvotes: 1