tags:

views:

122

answers:

1

I'm working with a demo of two sortable jquery lists... but have a problem when one list is empty, I can no longer drag items onto it, because there is nothing there to drop on. I tried adding space to the margin, padding and line-height of the ul, but nothing seems to work. Any ideas?

<style type="text/css">
#sortable1, #sortable2 {
    list-style-type: none;
    margin: 0;
    padding: 0;
    float: left;
    margin-right: 10px;
}
#sortable1 li, #sortable2 li {
    margin: 0 5px 5px 5px;
    padding: 5px;
    font-size: 1.2em;
    width: 120px;
}
</style>
<script type="text/javascript">
$(function() {
    $("#sortable1, #sortable2").sortable({
        connectWith: '.connectedSortable'
    }).disableSelection();
});
</script>

<ul id="sortable1" class="connectedSortable">
<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>
</ul>

<ul id="sortable2" class="connectedSortable">
</ul>
+1  A: 

Set the dropOnEmpty property to true. See http://jqueryui.com/demos/sortable/#empty-lists for more information.

Frederik Vig
Thanks - that works. I hate it when I search for something and the answer was on the same page :)
Adam