DMH*_*DMH 3 javascript jquery highcharts
我正在使用 Highchart 库。我通过格式化程序函数回调创建了一个工具提示,并在工具提示中插入一个链接。
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;
}
Run Code Online (Sandbox Code Playgroud)
现在我想在点击时调用 ajax 但点击事件没有触发。
jQuery('.comments_buble').on('click', function(e) {
//ajax call here
})
Run Code Online (Sandbox Code Playgroud)
这是代码
页面加载后,工具提示会动态附加到 DOM,因此您需要使用委托的事件处理程序:
$(document).on('click', '.comments_buble', function(e) {
// ajax call here
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1440 次 |
| 最近记录: |