0

I'm trying to use a jQuery Tooltip in a JSF application where I use Primefaces (so, jQuery is automatically loaded by Primefaces), but I get the following error:

Uncaught TypeError: $(...).tooltip is not a function

I use the tooltip function in this way:

<script type="text/javascript">

        // DOM Ready
        $(function() {

        //jQuery Tooltip
         $( document ).tooltip();
    });

    </script>

UPDATE

If I "manual" include jquery-ui it works:

<h:outputScript name="scripts/jquery/jquery-ui.min.js"/>

PF 6.0 (with jQuery v1.11.3) WildFly 10

Neo
  • 1,337
  • 4
  • 21
  • 50
  • Have you imported the right file? would it be possible to have your HTML aswell – Nicolas Feb 23 '17 at 13:34
  • Check the way you include the tooltip JS code. It does not recognise the function. It may be that the URL tot eh JS file which has the tooltip function in it is not correct. We can only guess because we do not have enough info in your post. – Manuel Cheța Feb 23 '17 at 13:34
  • I use primefaces, so the jQuery and jQuery ui should be already be included (and they are, I can use jQuery functions within my *.xhtml Files), but for some reasons the function "tooltip" cannot be found – Neo Feb 23 '17 at 13:44
  • this question might help you http://stackoverflow.com/questions/7857324/how-to-include-jquery-library-for-jsf-with-primefaces-ui – David Florez Feb 23 '17 at 14:29
  • Thx, I have already tried it without success (I have some PF tags in my xhtml page, so jQuery should really be loaded) – Neo Feb 23 '17 at 14:58
  • why can't you use primefaces [tooltips](http://www.primefaces.org/showcase/ui/overlay/tooltip/tooltipOptions.xhtml)? – David Florez Feb 23 '17 at 15:08
  • I need to set a tooltip for a -element – Neo Feb 23 '17 at 15:17
  • have you try just adding the `title` property to your element , that should work – David Florez Feb 23 '17 at 15:24
  • Yes, it works. But then I want to use the jQuery Tooltip to show the tooltip (and not the browser default tooltip) – Neo Feb 23 '17 at 15:29
  • then use the [global tooltip](http://www.primefaces.org/showcase/ui/overlay/tooltip/tooltipGlobal.xhtml) in addition to the `title` property – David Florez Feb 23 '17 at 15:55
  • I didn't know it, thx for the suggestion – Neo Feb 24 '17 at 06:23

1 Answers1

1

tooltip is part of jquery ui, but not of jquery (look here for differences). PrimeFaces uses jQuery, but only parts of jquery ui. tooltip is not part of it. So you can't use tooltip with PrimeFaces only. You have to load it yourself like you did in your question. But be careful that you choose a jquery ui version that is compatible with PrimeFaces' jquery version.

Community
  • 1
  • 1
Alex Fire
  • 707
  • 3
  • 7