[英]JQuery Tooltip - reversing tooltip().off(mouseover mouseleave)
So basically, I'm trying to create a form that shows tooltips on mouseover. 因此,基本上,我正在尝试创建一个在鼠标悬停时显示工具提示的表单。 Once one of the fields has been clicked, I want to disable the cursor from triggering other tooltips.
单击其中一个字段后,我想禁止光标触发其他工具提示。 Once the user clicks outside of the text box, I want the mouse to resume triggering tooltips.
用户在文本框外单击后,我希望鼠标恢复触发工具提示。
My problem - I've got everything working, except I can't turn the mouse listeners back on. 我的问题-除了无法打开鼠标侦听器之外,其他所有功能都可以正常工作。 Code is as follows:
代码如下:
$(function () {
infoTips();
});
function infoTips(){
$("input:text").tooltip({
content : function(){
return $(this).attr("title");
},
position : {
my : "left top",
at : "right top",
of : ".tip"
}
}).on("focusin", function () {
$("*").tooltip().off("mouseover mouseout mouseleave");
}).on("focusout", function () {
//This line doesn't work -
$("*").tooltip().on("mouseover mouseout mouseleave");
//
});
}
http://jsfiddle.net/kjhansen/WmRuN/480/ http://jsfiddle.net/kjhansen/WmRuN/480/
Thank you! 谢谢!
I changed the selectors to "this" and changed "off" to "remove" so it looks like this: 我将选择器更改为“ this”,并将“ off”更改为“ remove”,因此如下所示:
}).on("focusin", function () {
$(this).tooltip().remove("mouseover mouseout mouseleave");
}).on("focusout", function () {
$(this).tooltip().on("mouseover mouseout mouseleave");
});
jQuery does not keep the handlers in memory when you turn them off. 当您关闭处理程序时,jQuery不会将其保留在内存中。
For your situation, I believe you could just enable/disable the jQuery tooltips. 对于您的情况,我相信您可以启用/禁用jQuery工具提示。
Edit: Updated to exclude current input. 编辑:更新以排除当前输入。
ie 即
function infoTips(){
var $inputsWithTooltips = $("input:text");
$inputsWithTooltips.tooltip({
content : function(){
return $(this).attr("title");
},
position : {
my : "left top",
at : "right top",
of : ".tip"
}
}).on("focusin", function () {
$inputsWithTooltips.not(this).tooltip("disable");
}).on("focusout", function () {
$inputsWithTooltips.not(this).tooltip("enable");
});
}
edit: jsfiddle: http://jsfiddle.net/WmRuN/485/ 编辑:jsfiddle: http : //jsfiddle.net/WmRuN/485/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.