Removing empty space with jQuery after deleting Selectable item
I have two ordered lists and user can move items between them. I am using jQuery UI's Selectable for both of them. Problem is that when I move item from the middle of the list it leaves an empty space behind. How can I make list shrink according to the how many items is actually in the list?
HTML
<ol id="allUnits">
<li class="ui-state-default">Item 1</li>
<li class="ui-state-default">Item 2</li>
<li class="ui-state-default">Item 3</li>
<li class="ui-state-default">Item 4</li>
<li class="ui-state-default">Item 5</li>
</ol>
<input id="arrowRight" type="image" alt="Move item to right" src="<%= Url.Content("~/Content/Images/arrowRight.png")%>" />
<input id="arrowLeft" type="image" alt="Move item to left" src="<%= Url.Content("~/Content/Images/arrowLeft.png")%>" />
<ol id="productUnits">
<li class="ui-state-default">Item 1</li>
<li class="ui-state-default">Item 2</li>
<li class="ui-state-default">Item 3</li>
<li class="ui-state-default">Item 4</li>
<li class="ui-state-default">Item 5</li>
</ol>
jQuery
$().ready(function () {
$("#allUnits").selectable();
$("#productUnit开发者_运维问答s").selectable();
$('#arrowRight').click(function () {
return !$('#allUnits .ui-selected').remove().appendTo('#productUnits').removeClass(".ui-selected");
});
$('#arrowLeft').click(function () {
return !$('#productUnits .ui-selected').remove().appendTo('#allUnits').removeClass(".ui-selected");
});
});
Okay, it seems to work now. Maybe it was some kind of CSS or space issue, but suddenly it works! Lets forget this question...
精彩评论