jerosoler / Drawflow

Simple flow library 🖥️🖱️

Home Page:https://jerosoler.github.io/Drawflow/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to access the JSON data passed to the node

nebc-jasonfung opened this issue · comments

I am using editor.addNode function and passing in a JSON object via the data attribute. How do I get this data when that node is clicked?

Looks like this can be solved by doing the following:

editor.on('nodeSelected', (id) => {
    console.log(editor.getNodeFromId(id).data.name);
});

editor.addNode('foo', 1, 1, 100, 100, 'foo', {name: 'test'}, "<p>Test</p>");