【发布时间】:2014-11-30 20:00:26
【问题描述】:
我有两个块,一个是“可拖动的”,另一个是“可排序的”。
当我开始从“可排序”中拖动一个项目时,我想为 div 添加背景颜色,如果我停止拖动它,我想删除背景颜色。
这是我的 JS:
$(".sortableList").sortable({
start: function(event, ui) {
if (event.handleObj.namespace=="sortable")
$('.background').show();
},
update: function(event, ui) {
if (event.handleObj.namespace=="sortable")
$('.background').hide();
}
});
$(".draggable").draggable({
connectToSortable: '.sortableList',
cursor: 'pointer',
helper: 'clone',
revert: 'invalid',
start: function (event, ui) {
$(this).addClass('testing');
}
});
这是一个jsbin,其中包含一个我正在尝试做的活生生的例子。
问题是,当我开始从“可排序”中拖动一个项目并将其放在同一个位置时,背景颜色保持不变,我没想到会这样。
我该怎么做?
【问题讨论】:
-
如果您在documentation 上花费了一些时间,您也许可以使用limit 和rate 的questions..
标签: javascript jquery jquery-ui jquery-ui-sortable