方案:我使用了自動完成的組件和infront我使用了一個命令鏈接與搜索圖像。Primefaces自動完成:如何在點擊命令鏈接後將焦點設置爲自動完成
我的目的是在點擊commandlink後在自動完成中顯示光標。
我的代碼如下:
自動完成:
<p:autoComplete id="senderAutocomplete" widgetVar="senderInfo"
value="#{customerReviewLazyDataModel.customerReviewVO.senderVO}"
completeMethod="#{customerReviewLazyDataModel.searchOrganizations}"
var="senderVO"
itemValue="#{senderVO}" converter="organizationConverterForCustomerReview"
size="60">
commandlink
<p:commandLink oncomplete="setFocus()" ajax="true">
<p:graphicImage value="/app-resources/themes/yob/images/search.png" style="margin-bottom: -4px;"></p:graphicImage>
</p:commandLink>
js函數
function setFocus(){
document.getElementById("senderAutocomplete").focus();
}
有沒有解決這個問題的方法?
謝謝。你的答案解決了我的問題。我用'document.getElementById(「senderAutocomplete_input」)。focus();'這和它工作得很好。 – Shruti