【问题标题】:Can't get endpoints' uuids or labels using jsPlumb无法使用 jsPlumb 获取端点的 uuid 或标签
【发布时间】:2018-04-20 13:11:50
【问题描述】:

这是我在 StackOverflow 上的第一个问题。

我目前正在使用 jsPlumb 来制作一种图表。图表的每个节点都可以有多个输入和输出,因此我在每个端点上标记并放置了一个 uuid:

jsPlumb.addEndpoint("name of node",
{
    anchor : [0,0.75,-1,0],
    overlays : [ ["Label", {label : "name of input", uuid : "name of input", location : [3.5,0.5]}] ]
}, targetEndpointOptions);

然后我尝试使用此函数获取端点的标签或 uuid:

function getConnexions()
{
    var connected = jsPlumb.getConnections();
    $.each(connected, function(id, connection)
    {
        console.log(connection.source);
        console.log(connection.target);

        console.log(connection.endpoints[0].getUuid());

        $.each(connection.endpoints, function(id, endpoint)
        {
            console.log(endpoint.getLabel());
        })
    })
}

如您所见,我尝试了两种不同的方法来处理标签和 uuid。但这不起作用,我在控制台中得到 undefined 或 null 。有人可以帮忙吗?

非常感谢

【问题讨论】:

  • 嗨@user9674896。我通常会编辑第一篇文章,但在你的情况下 - 没有必要这样做。第一个问题的格式很好。欢迎使用 StackOverflow,祝你好运!

标签: javascript jsplumb


【解决方案1】:

您已将 uuid 放置在标签上而不是端点上。如果您尝试将 uuid 放在端点上,请尝试:

jsPlumb.addEndpoint("name of node",
{
    anchor : [0,0.75,-1,0],
    uuid : "name of node",
    overlays : [ ["Label", {label : "name of input", location : [3.5,0.5]}] ]
}, targetEndpointOptions);

【讨论】:

  • 抱歉,反馈迟了,我想我想出了另一种方法来做到这一点。但这确实是问题所在,非常感谢! :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-19
  • 1970-01-01
相关资源
最近更新 更多