单击滚动条后,Primefaces自动完成关闭 [英] Primefaces autocomplete close after click on scroll bar
问题描述
我正在使用Primefaces 6.2.
I am using Primefaces 6.2.
我的问题是当我对dropDown=true
和scrollHeight
使用autoComplete时.单击滚动条后,窗口关闭.当我只在鼠标上使用滚轮时,效果很好.
My problem is when I use autoComplete with dropDown=true
and scrollHeight
. Window close after I click on scroll bar. It works fine when I just use wheel on my mouse.
<p:autoComplete id="agendaSelect" scrollHeight="100" completeMethod="#{agendaAutoCompleteView.completeAgenda}" dropdown="true" itemValue="#{agenda}" var="agenda" itemLabel="#{agenda.displayName}" forceSelection="true" value="#{agendaAutoCompleteView.agenda}" converter="agendaConverter" required="true" requiredMessage="Pole Agenda musi byt vyplnene.">
<p:ajax event="itemSelect" update="bunkaSelect" listener="#{bunkaAutoCompleteView.bunkaListener}" />
</p:autoComplete>
推荐答案
作为临时修复,直到修复了bug,您可以在页面上的某处(例如,在加载时)使用以下JS代码.
As temporary fix until the Bug is fixed you might use the following JS-Code somewhere on your page (e.g. upon onload).
$('body').on('mousedown', '.ui-autocomplete-panel', function(event) { event.stopImmediatePropagation();});
这将防止执行当前导致不当行为(关闭面板)的事件.它也适用于部分请求/响应,因为该事件将应用于将来的同一类的DOM元素.
This would prevent the event currently leading to misbehaviour (closing the panel) to be carried out. It will work also for partial Requests/Responses as the event would be applied to future DOM Elements of the same class.
这篇关于单击滚动条后,Primefaces自动完成关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!