Reputation: 801
What 's the best way to execute a commandButton on the onchange event of an inputText?
I'm trying to build a dynamic search result while user digit string.
<p:inputText id="txtSearch" value="#{contattiDitteController.search}">
</p:inputText>
<p:commandButton id="btnSearch" value="Search" action="#{contattiDitteController.actionSearch}" update="pnlResult"/>
I'm using this, but is the best way (or I can do better with primeface)?
<script>
function refresh() {
jQuery('[id$="btnSearch"]').click();
}
</script>
<p:inputText id="txtSearch" value="#{contattiDitteController.search}" onkeypress="refresh();"/>
<p:commandButton id="btnSearch" value="Search" action="#{contattiDitteController.actionSearch}" update="pnlResult"/>
Upvotes: 3
Views: 18712