首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >单击“高级图表”工具提示中的“不触发事件”

单击“高级图表”工具提示中的“不触发事件”
EN

Stack Overflow用户
提问于 2015-07-28 06:52:09
回答 2查看 2K关注 0票数 3

我在使用高级图表库。我通过格式化函数回调创建一个工具提示,并在工具提示中插入一个链接。

代码语言:javascript
复制
 config.tooltip.formatter = function(){
                    //console.log(this)
                    var tooltipHTML = "<b>✔ " + this.y + "% - " + this.key + "</b>";
                    var userImg = $('.user-picture').html();
                    if (userImg) {
                        tooltipHTML += "<div class='user-avatar-comment'>";
                        tooltipHTML += userImg;
                        tooltipHTML += "</div>";
                    }
                    tooltipHTML += "<div class='comment_filter'><a class='comments_buble' href='#' data-series='" + this.point.index + "'>Comment</a></div>";

                    return tooltipHTML;
                }

现在,我想在单击时调用ajax,但单击event触发。

代码语言:javascript
复制
jQuery('.comments_buble').on('click', function(e) {
//ajax call here
})

这是密码

http://jsfiddle.net/vxnq3578/3/

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-07-28 07:01:53

工具提示在加载页面后动态地附加到DOM中,因此您需要使用委托的事件处理程序:

代码语言:javascript
复制
$(document).on('click', '.comments_buble', function(e) {
    // ajax call here
})
票数 5
EN

Stack Overflow用户

发布于 2019-01-25 13:15:22

代码语言:javascript
复制
=> by default all events are reset on container
=> events are triggered from the one level not bubbled
=> tooltip is created "on the fly", so your jQuery has reference to object which does not exist.
=> mixing SVG / HTML elements does not allow you to use CSS pointer-events properly.

所以您可以通过tooltip.style演示:http://jsfiddle.net/BlackLabel/4q9kga7e/1/来允许它们

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31669246

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档