简体   繁体   English

如何永久显示 ap:tooltip?

[英]How to permanently show a p:tooltip?

I'm trying to permanently show the p:tooltip in a PrimeFaces project I'm working on.我正在尝试在我正在处理的 PrimeFaces 项目中永久显示p:tooltip
This is my current code:这是我当前的代码:

<p:graphicImage id="testImg" name="/img/testImg.jpg" onclick="PF('info').show();" style="cursor: pointer"/> 
<p:tooltip for="testImg" value="further information" position="right" />
<p:dialog widgetVar="info" modal="true" closeOnEscape="true" >
    <h:outputText value="bla bla bla"/>
</p:dialog>

I tried this:我试过这个:

<p:tooltip for="testImg" value="further information" position="right" showEevent="permanent"/>

but it didn't work.但它没有用。

Is there any way to control the tooltip and have it permanently visible without having to mouse over or focus the controlling element?有什么方法可以控制工具提示并使其永久可见,而无需将鼠标悬停在控制元素上或聚焦控制元素上?

As you have noticed, there is no show event called permanent.正如您所注意到的,没有称为永久的表演事件。 What you could do is controlling the tooltip with JavaScript using a widget variable.您可以做的是使用小部件变量通过 JavaScript 控制工具提示。 You can assign one for the tooltip using the widgetVar attribute.您可以使用widgetVar属性为工具提示指定一个。 The tooltip widget has several functions, one of them is show() (to show the tooltip). 工具提示小部件有几个功能,其中之一是show() (显示工具提示)。
When the tooltip is shown there is a delay of 150 msec, so set that to 0 to immediately show the tooltip.显示工具提示时有 150 毫秒的延迟,因此将其设置为 0 以立即显示工具提示。 To prevent the tooltip from being hidden, set the hideEvent to some non existing event (like none ).为了防止工具提示被隐藏,请将hideEvent设置为某个不存在的事件(如none )。

Putting it all together:把它们放在一起:

<h:panelGrid columns="3">
  <h:outputText value="Permanent" />
  <p:inputText id="permanent"
               title="Permanent tooltip" />
  <p:tooltip id="permanentTip"
             for="permanent"
             widgetVar="permanentTip"
             showDelay="0"
             hideEvent="none"/>
</h:panelGrid>

<script>
  $(function(){ 
    PF('permanentTip').show();
  });
</script>

See also:也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM