我正在使用twiiter-bootstrap的tooltip,我想发出ajax请求,或者在工具提示关闭时说出一个警告框。 jquery代码是:
$(document).ready(function(){
$('#explore').tooltip({
content : "hi there",
placement : 'bottom',
});
});
我还尝试了其他插件,比如jquery的tooltip和craigworks的qtip,但是当工具提示关闭时,我无法找到解决回调的方法。
即使工具提示无法支持,我可以使用其他东西,比如bootstrap的popover或其他一些解决方法吗?
我想要实现的目标是: 我有一个div,里面有一个按钮。如果用户单击该按钮,则按钮旁边会出现一个小对话框,要求提供其他信息。用户可以 (1)忽略它并单击屏幕上的任何其他位置以关闭对话框 (2)单击“关闭”按钮关闭对话框 (3)提交问题的答案以关闭对话框
在所有3个案例中,我希望将div替换为另一个获取ajax的内容。 如果工具提示有一个回调,那就不错了。
答案 0 :(得分:0)
似乎没有本地方法通过.tooltip
执行此操作,但您可以选择触发工具提示显示的内容,以便您可以将自己的事件绑定到相反的位置。默认(您使用的是)'hover'
:
$("#explore").tooltip().on('mouseout', function () { alert('left tooltip'); });
答案 1 :(得分:0)
我能够使用插件的events
属性使用Craig的qtip来解决这个问题:
$(document).ready(function(){
$('.overlay-seen-it').qtip({
overwrite: false,
content: {
text: "Hi there"
},
show: {
event: 'click',
solo: true
},
hide:{
event: 'unfocus'
},
events:{
hide: function(event, api){
var movie=api.elements.target.closest('.movie');
movie.fadeOut(500, function(){
$.get('reco_product_stream.jsp?type=replace', function(data) {
var $a = $(data).find('a');
movie.children('a').replaceWith($a);
movie.fadeIn(500);
});
});
}
}
});
});
qtip关闭时,events:hide
属性中列出的任何函数都会触发。由Craig here解决。