JointJS : How to restrict links per port to one?

jointjs

Solution

It was as simple as getting element from graph and setting certain attribute on it.

var source = graph.getCell(sourceId);
source.attr('.outPorts circle/magnet', 'passive')

Problem

API doc for the JointJS library is here: http://www.jointjs.com/api I'm using DEVS plugin for Elements with ports. I need to restrict number of connections from a port to a single one. Once a link is made from a port, user shouldn't be able to start a connection from the same port unless the existing connection is removed. Is it possible without code changes in the library itself? I was not able to get a hook/entry point to implement this requirement even after looking into API doc and the code itself. Any help or pointers are appreciated. PS: - unfortunately I'm not good at Backbone at the moment. - it was matter of setting magnet="passive" to the port in question, I guess. Just don't know how to do it. (graph is dynamic, not predefined links between elements)

Original source