Feathers <p: tooltip> do not disappear after another Ajax request

Let's say I have clues in mine <p:dataTable>

. When I change the page dataTable

while the other page is with my palms, I move the mouse over any tooltip - it appears, but after loading another page, the tooltip never disappears. I tried to update it using p:ajax

, p:remoteCommand

but nothing helps, in fact it caused another request Ajax

and tooltips. Only a full page reload is performed F5

.

Has anyone faced such a problem? Many thanks for your help!

+3


source to share


1 answer


This looks like a PrimeFaces bug, but you can work around it by hiding the pagination event tooltips via JS.

<p:dataTable value="#{bean.val}" var="row" rowIndexVar="rowIndex" rows="10" paginator="true">
    <p:ajax event="page" oncomplete="hideTooltips();" />

    <p:column>
        <h:outputText id="text" value="#{row}" />
        <!--
            since p:tooltip is located inside an iterative component (p:dataTable), we can't
            just define a static widgetVar value, because there will be a widget instance for
            each iteration, and each instance must have a unique widgetVar value, so we'll
            use rowIndex to achieve that
        -->
        <p:tooltip widgetVar="textTipVar#{rowIndex}" for="text" value="Tip" />
    </p:column>
</p:dataTable>
<script>
    function hideTooltips() {
        /*
            we've defined a bunch of widgetVars with a dynamic name, so we'll iterate over
            all widgets on the page and find the ones we need by looking for a known
            widgetVar prefix
        */
        for (var w in PrimeFaces.widgets) {
            if (w.indexOf('textTipVar') === 0) {
                PrimeFaces.widgets[w]._hide();
            }
        }
    }
</script>

      



This uses the undocumented Tooltip widgets method _hide

, keep this in mind when upgrading to another version of PrimeFaces for example. the method name may change. The object is PrimeFaces.widgets

also undocumented.

+3


source







All Articles