【问题标题】:Mouse hover event in GetorgchartGetorgchart 中的鼠标悬停事件
【发布时间】:2018-05-11 17:23:13
【问题描述】:

Getorgchart 视图中的鼠标悬停事件。如何在 Getorgchart 视图中编写鼠标悬停事件和鼠标移出事件。我应该在鼠标悬停/离开时获取组织结构图元素的详细信息吗?

【问题讨论】:

    标签: javascript orgchart getorgchart


    【解决方案1】:

    您可以将鼠标悬停事件附加到每个节点。这是一个例子

    var orgchart = new getOrgChart(document.getElementById("people"), {
        updatedEvent: mouseoverListener,
        dataSource: [
            { id: 1, parentId: null, Name: "Amber McKenzie" },
            { id: 2, parentId: 1, Name: "Ava Field" },
            { id: 3, parentId: 1, Name: "Evie Johnson" }]
    });
    
    function mouseoverListener() {
        var boxes = document.querySelectorAll("[data-node-id]");
        for (i = 0; i < boxes.length; i++) {
            boxes[i].addEventListener("mouseover", function () { alert("hovered node ID is " + this.getAttribute("data-node-id")) });
        }
    }
    
    mouseoverListener();
    

    【讨论】:

    • 是否可以使用此方法在特定框中显示按钮,例如当我将鼠标悬停在将显示该按钮的框上时,我们也可以单击它,仅在该框上显示而不在其他框上显示, @balkanGraph
    • 是的,有可能。您在使用 BALKAN OrgChartJS balkan.app/OrgChartJS,请注意不再支持 GetOrgChart 库
    猜你喜欢
    • 2018-08-13
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 2020-06-25
    • 2011-11-09
    • 2011-08-17
    • 1970-01-01
    • 2012-10-12
    相关资源
    最近更新 更多