使用 twitter bootstrap 创建工具提示/弹出框后的回调函数? [英] Callback function after tooltip / popover is created with twitter bootstrap?

查看:20
本文介绍了使用 twitter bootstrap 创建工具提示/弹出框后的回调函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在使用 twitter bootstrap 创建工具提示或弹出框后对其进行操作.据我所知,没有构建方法可以做到这一点.

I want to manipulate a tooltip or popover after it is created with twitter bootstrap. As far as i know there isn't a build in way to do this.

$('#selector').popover({
  placement: 'bottom'
});

例如,假设我想将创建的工具提示从计算位置向上移动 5px 并向左移动 5px.关于做到这一点的最佳方法有什么想法吗?

For example lets say i want to move the created tooltip up 5px and left 5px from it's calculated location. Any ideas on the best way to do this?

这就是我想做的:

$('#selector').popover({
  placement: 'bottom',
  callback: function(){
    alert('Awesome');
  }
});

推荐答案

适用于工具提示:

var tmp = $.fn.tooltip.Constructor.prototype.show;
$.fn.tooltip.Constructor.prototype.show = function () {
  tmp.call(this);
  if (this.options.callback) {
    this.options.callback();
  }
}

this.$('#selector').tooltip({ 
  placement: 'top', 
  callback: function() { 
    alert('hello') 
  } 
});

这篇关于使用 twitter bootstrap 创建工具提示/弹出框后的回调函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆