我有这个代码
function DrawTipsProgress(postid, ajaxurl) {
var data = {
action: 'ajax_action',
post_id: postid
}
jQuery('#dashicon-' + postid).on("click", function () {
jQuery.post(ajaxurl, data, function(response) {
jQuery('#dashicon-' + postid).tooltip({
position: { my: 'center bottom' , at: 'center top-10' },
tooltipClass: "myclass",
content: response
});
jQuery('#dashicon-' + postid).tooltip('open');
});
});
}在第一次单击时,它的工作方式与方面相同。如果稍后我再次尝试将鼠标悬停在按钮上而不单击它,则会再次弹出工具提示,而单击只是执行ajax调用,但没有打开工具提示。
发布于 2015-02-27 22:45:50
工具提示在悬停时触发。在你的代码中,直到' click‘事件发生,它才会被绑定到元素,所以它实际上并不是导致它显示的点击……这是鼠标点击后的悬停。我相信你需要做的就是使用enable和disable。这是一个小提琴的例子。http://jsfiddle.net/ecropolis/bh4ctmuj/
<a href="#" title="Anchor description">Anchor text</a>
$('a').tooltip({
position: { my: 'center bottom' , at: 'center top-10' },
tooltipClass: "myclass",
disabled: true,
close: function( event, ui ) {
$(this).tooltip('disable');
/* instead of $(this) you could also use $(event.target) */
}
});
$('a').on('click', function () {
$(this).tooltip('enable').tooltip('open');
});https://stackoverflow.com/questions/28767137
复制相似问题