【问题标题】:Protovis jQuery tipsy doesn't work with click eventProtovis jQuery Tipsy 不适用于点击事件
【发布时间】:2011-10-12 02:35:37
【问题描述】:

我在我的图表上喝醉了。 mouseover 事件运行良好,但是当我添加 click 事件时,它并没有按照我的意愿执行 click 事件。

下面是我的代码:

var vis = new pv.Panel()
            .width(w)
            .height(h);

            vis.add(pv.Bar)
            .data(data)
            .width(4)
            .left(function() 5 * this.index)
            .height(function(d) Math.round(d*4))
            .bottom(0)
            .text(function(d) d.toFixed(1))
            .event("mouseover", pv.Behavior.tipsy({gravity: "w", fade: true}))
            //If I remove the mouseover event, the click event will work but not when both are veing put together.
            .event("click", function() self.location = "http://stanford.edu");

            vis.render();

谁能帮我解决这个问题?

【问题讨论】:

    标签: javascript jquery jquery-events tipsy protovis


    【解决方案1】:

    这里有一个解决方法。您可以将点击回调函数传入 pv.Behavior.tipsy 并在其中调用点击事件。

    1. 修改 pv.Behavior.tipsy(...) 以传入回调函数:

      pv.Behavior.tipsy = 函数(选择,回调)

    2. 修改事件调用以传入回调函数:

      .event("mouseover", pv.Behavior.tipsy({gravity: "w", fade: true}, function(){alert('click call back');}))

    3. 修改protovis.tipsy.js中返回函数的最后一行:

      返回函数(d) { ………… $(tip).mouseleave(cleanup).tipsy("show"); 如果(回调){ $(tip).click(回调); } };

    【讨论】:

    • 太好了,当我遇到同样的问题时,这对我有用。
    猜你喜欢
    • 2019-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-24
    • 2017-06-10
    • 2014-12-29
    相关资源
    最近更新 更多