从列表 #2 到列表 #1 我想克隆元素。
我正在使用可排序和可放置的。但是克隆部分永远不会起作用!
jsfiddle:http: //jsfiddle.net/46zqm/6/
As you can see cloned part gets stuck in the tab navli.
完整代码:
// Initiate jquery ui sortable
$(".word-list").sortable({
tolerance: 'pointer',
cursor: 'move',
forcePlaceholderSize: true,
dropOnEmpty: true,
connectWith: 'ol.word-list',
placeholder: "ui-state-highlight"
}).disableSelection();
// Words tabs
var $tabs = $("#tabs").tabs({active: 1});
// Make tab names dropable
var $tab_items = $("#tabs-nav li", $tabs).droppable({
accept: ".word-list li",
hoverClass: "ui-state-hover",
tolerance: 'pointer',
drop: function(event,ui) {
// Deduce source and target
var source = $(ui.draggable[0]).parent().attr("id").split("-")[1];
var target = $(event.target).children("a").attr("href").split("-")[1];
// 1 = Top words, 2 = All words, 3 = Deleted
console.dir("source:" + source);
console.dir("target:" + target);
// If droped on self, do nothing
if (source == target) {return false;}
//
var $item = $(this);
var $list = $($item.find("a").attr("href"));
if (source == 2 && target == 1) {
$tabs.tabs("option", "active", $tab_items.index($item));
ui.draggable.clone().appendTo($list);
} else {
ui.draggable.hide("fast", function() {
$tabs.tabs("option", "active", $tab_items.index($item));
$(this).appendTo($list).show("slow");
});
}
}
});