【发布时间】:2014-06-11 04:54:42
【问题描述】:
我试图避免在使用jsPlumb 时出现重复连接(2 个具有相同源和目标的连接)。有没有办法做到这一点而不必修改 jsPlumb.js 本身?
http://jsfiddle.net/uQdfq/
(从task1 拖动到task3 两次)
我不想有添加特定端点的限制,例如 (1)。
我的.tasks 在被调用时被定义为可能的目标/源 - 也就是说,整个 div 可以是源/目标,而不仅仅是某个端点:
addTask($('#project1'), 'task' + 1);
函数本身:
// Adds a task div to the specific project
function addTask(parentId, id) {
var newState = $('<div>').attr('id', id).addClass('task')
// A title for the task
var title = $('<div>').addClass('title').text(id);
newState.append(title);
$(parentId).append(newState);
// Makes the task div a possible target (i.e. connection can be dragged to)
jsPlumb.makeTarget(newState, {
anchor: 'Continuous'
});
// Makes the task div a possible source (i.e. connection can be dragged from)
jsPlumb.makeSource(newState, {
anchor: 'Continuous'
});
}
添加一些条件以阻止创建重复连接的可能性的最佳方法是什么。
【问题讨论】:
标签: javascript jquery jsplumb