我想在单击节点时显示模态,但我不知道如何将数据传递给模态,以及如何显示模态。
我找到的所有例子,点击按钮后显示模态等,
HTML:
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
<script>
</script>
</div>
</div>
JS:
<script>
// Generate graph:
// Instantiate sigma:
// binding sima instance to an event
s.bind('doubleClickNode ', function(e) {
var id = e.data.node.neo4j_data['ID'];
$('#MyModal').append('<p class="navbar-text">ID: '+ id +'</p>');
$("#MyModal").modal();
});
</script>
答案 0 :(得分:0)
我找到了这个足够好的解决方案
s.bind('doubleClickNode ', function(e) {
console.log("node is clicked!");
var id = e.data.node.neo4j_data['ID'];
var modal = document.getElementById('myModal');
$('#my_label').html ( id ); // my_label inside modal
$('#myModal').modal('show')
});