0

我想在单击节点时显示模态,但我不知道如何将数据传递给模态,以及如何显示模态。

我找到的所有示例,单击按钮后显示模态等,

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">&times;</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>
4

1 回答 1

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')            

        });
于 2016-04-30T04:35:42.547 回答