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

查看:122
本文介绍了使用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天全站免登陆