Atul Raut
Atul Raut

Reputation: 21

How to get custom element by id in JointJS

I want to get element by id and change position of that element

please find following code:

function addInNodes(x, y, text, ){
    inPortsMarkup += '<g class="port port_0'  style="pointer-events: none" id="in_0" >';
    inPortsMarkup += '<rect height="12" width="2" y="5" x="'+ x +'" class="port-wire" fill="#253137" stroke-width="1" transform="rotate(-90)" style="pointer-events: none" />';
    inPortsMarkup += '<circle port="'+ text +'" type="input" magnet="active" r="7" class="port-body" fill="#bcbcbc" stroke="#747474" stroke-width="1" transform="translate(-1,'+y+')" style="pointer-events: fill"/>';
    inPortsMarkup += '</g>';
}

I have tried var myElements = graph.getElements(); but its not working for me.

Thanks in advance.

Upvotes: 2

Views: 3227

Answers (1)

Destrif
Destrif

Reputation: 2134

You used:

getElements graph.getElements()

Get all the elements in the graph (i.e. omit links).

And should use

to get all elements, even links:

getCells graph.getCells()

Get all the element and links in the graph.

Upvotes: 3

Related Questions