如何使用jquery将项目移至空白列表? [英] How do I move an item to an empty list using jquery?

查看:68
本文介绍了如何使用jquery将项目移至空白列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在演示两个可排序的jquery列表的演示...但是当一个列表为空时出现问题,我无法再将项目拖到该列表上,因为没有可放置的内容.我尝试为ul的边距,填充和行高添加空间,但似乎没有任何效果.有什么想法吗?

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>

推荐答案

将dropOnEmpty属性设置为true.请参阅 http://jqueryui.com/demos/sortable/#empty-lists 更多信息.

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

这篇关于如何使用jquery将项目移至空白列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆