API crashes on 2nd render() call
See original GitHub issueHey everyone,
I successfully set up my site to read input from a textarea and make it rerender with MermaidAPI. The first time I change the input in the textarea, the graph changes as expected.
But the second time I change the textarea I get the following error:
:WARN: TypeError: Cannot read property ‘v’ of undefined at Object.edgeToId (mermaidAPI.js:10650) at SVGGElement.<anonymous> (mermaidAPI.js:9661) at bind (mermaidAPI.js:851) at Array.d3_selectionPrototype.data (mermaidAPI.js:903) at createEdgeLabels (mermaidAPI.js:9661) at fn (mermaidAPI.js:10401) at Object.exports.draw (mermaidAPI.js:50877) at render (mermaidAPI.js:58254) at Object.exports.render (mermaidAPI.js:58345) at HTMLTextAreaElement.<anonymous> ((index):40)
The code I used is as follows:
$('#cfgTextarea').change(function(emt) {
var graphStr = emt.target.value;
var correct = mermaidAPI.parse(graphStr);
if (correct) {
var graph = mermaidAPI.render(graphStr);
$('#mermaidContainer').html(graph);
} else {
$('#errorMsg').html('<br/>Wrong.');
}
});
I am baffled by this weird error and I can’t find out what really caused it. Any ideas?
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (3 by maintainers)
Top GitHub Comments
render can take 3 parameters. I faced the same problem and corrected it like that (I used Jquery but feel free to do it with JS) :
the value
SEE_BELOW
has to be changed at every call. You won’t have the error anymore.@jansennetive consider reopening the issue