问题
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
回答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.
来源:https://stackoverflow.com/questions/42417203/jquery-tooltip-with-primefaces-uncaught-typeerror-tooltip-is-not-a-func