简体   繁体   中英

Primefaces Autocomplete - How to display dropdown items on click of input

Using PF 4/5 and Mojarra 2.2

I have an autocomplete field with a dropdown being shown. The list of items displays when I click the dropdown or start typing in the input. I want the list of items to display when the input box gets focus so that essentially I can remove the dropdown button image. Im not sure how to trigger that.

<p:autoComplete minQueryLength="0" size="7" queryDelay="0" dropdown="true" scrollHeight="200" value="#{scheduleView.startTime}" id="startTime"  completeMethod="#{scheduleView.getTimes}" required="true" onclick="this.select()">

You can trigger client side's search() function on autocomplete input click :

<p:autoComplete
    id="startTime"
    widgetVar="foo"
    value="#{scheduleView.startTime}"
    completeMethod="#{scheduleView.getTimes}"
    required="true"
    dropdown="true"
    size="7"
    scrollHeight="200"
    minQueryLength="0"
    queryDelay="0"
    onclick="PF('foo').search(PF('foo').input.val());">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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