jerosoler / Drawflow

Simple flow library 🖥️🖱️
https://jerosoler.github.io/Drawflow/
MIT License
4.61k stars 721 forks source link

Add/Change node's className on connectionCreated #178

Closed adamburczy closed 3 years ago

adamburczy commented 3 years ago

what is the proper way to add/change className of node? I tried: editor.updateNodeDataFromId(5, { class : 'newclass' }) but it's not working, document.getElementById(id).classList.add('newclass'), is working but only when connectionCreated happen, for example, i can console.log the newclass at the end of connectionCreated event, but it is not really adding a className to node as well.

jerosoler commented 3 years ago

Hello @adamburczy

updateNodeDataFromId only update data values for df-attributes. Not update classes ...

use

 editor.drawflow.drawflow.Home.data[id].class = "newclass"

Jero

adamburczy commented 3 years ago

okay, good to know, thanks for help, have a nice day :)

adamburczy commented 3 years ago

Hi, I have one more issue about it. I need to add multiple classNames to node. Is there a way to do it? editor.drawflow.drawflow.Home.data[id].class = "newclass anotherclass" does not work, as well as calling this method with one class, 2 times, only class from second call is added.

adamburczy commented 3 years ago

solved.