当用户将鼠标悬停在输入上时,我想在错误上显示一个提示工具提示。如果用户修复了错误,我不希望在他们悬停时再显示提示工具提示。我有以下显示它,但我无法弄清楚当用户将鼠标悬停在输入框上时如何阻止它显示。有人可以帮忙吗?
$().ready(function () {
const initialTippy = tippy(document.querySelector('.tippy'));
}
// Simplified validation for this question.
function validate() {
if (isValid) {
// Kill the tippy message...which I need help with.
// initialTippy.destroy() does not work and I do not get an error.
}
else {
toggleErrorMessage('You have an error'); // Works when I hover over highlighted input box.
}
}
// If my input does not validate, this is called.
function toggleErrorMessage(message) {
tippy('.tippy', {
trigger: 'mouseenter',
onShow(instance) {
instance.setProps({ content: message });
}
});
}