【发布时间】:2013-10-07 01:17:45
【问题描述】:
如果我在初始化 .sortable 之后将元素添加到列表中,它就不能正常工作。
参见示例jsFiddle
示例 HTML:
<div class="container">
</div>
<br />
<button class="add-fields">add</button>
示例 JS:
$(".container").sortable({
containment: 'parent'
});
$(".container").disableSelection();
$(".add-fields").click(function(){
$(".container").append("<div>sucke</div>")
})
示例 CSS:
.container {
height: 30px;
width: 100%;
background: blue;
position: relative;
float: left;
}
.container > div {
position: relative;
float: left;
height: 100%;
width: 80px;
background-color: red;
line-height: 30px;
text-align: center;
margin: 0;
padding: 0;
cursor: default;
}
更新
我在这里找到了相关问题http://bugs.jqueryui.com/ticket/7498
因为 this.floating 只在 _create 中确定,如果你从 一个空的 sortable,它被假定为垂直的。
【问题讨论】:
-
它对我来说工作正常.. 我确实手动添加了一个,其中包含除了吸以外的单词。 div 的拖动和排序很好。也许所有具有相同名称的 div 都不会让这一点变得明显?
标签: javascript jquery jquery-ui jquery-ui-sortable