-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node click is not effective #272
Comments
No I think not. When I try you code it works fine. What version and browser are you one? |
thank you for your reply. the mermaid version is 0.5.6 , I try the code on chrome (47.0.2526.106) and firefox both. my code is here. ...
<script type="text/javascript">
var callback = function(){
alert('A callback was triggered');
}
mermaid.initialize({startOnLoad:false});
$(function(){
var html = mermaidAPI.render('panel', $('textarea').text());
$('#penel').html(html);
});
</script>
</head>
<body>
<div id="penel"></div>
<textarea style="width:100%;height:300px;">
graph LR;
A((start))-->B(step1);
B-->C[step2];
C-->D{step3};
D-->E[end];
classDef green cursor:pointer,fill:#9f6,stroke:#333,stroke-width:1px;
class A,B,C,D,E green;
click B callback "tooltip"
</textarea>
</body> by the way, if I click a node, could I get the parent node and children nodes, and the in-link, out-links? |
I see the problem now. As you are using the render function you need to bind the event handlers to the svg code you recieved after ijnserting it in to the dom. Look here for more info: There are unfortunately no support currently for the parent/children arguments to the callback for the click. |
thank you, I get it. I think there is some other way to bind click function, and also get the click node info. //get all nodes
var nodes = $('g[class="nodes"] g[class="node"]');
$(nodes).css({'cursor': 'pointer'});
$(nodes).on('click', function(){
//get current node
var id = $(this).attr('id');
var text = $(this).find('foreignObject div').html();
alert('id is ' + id + ', text is ' + text);
//get sibling nodes
//get in link
//get parent node
//get out link
//get children nodes
}); |
I defined a js function on page, and bind a click event to the node, but it is not effective, on the api guide, your demo is also not effect, but tooltip is ok.
the graph script is
is there something wrong with my code?
The text was updated successfully, but these errors were encountered: