Reputation: 495
I have an easy question.
I have few primefaces inputtext
and two primefaces commandbutton
on my xhtml page. When I press enter after edited the inputtext, it triggers one of my commandbutton.
But I want to trigger the other commandbutton. How to do that? And how it decide which commandbutton
is to be triggered? What is the reason there?
Thanks for help.
Upvotes: 3
Views: 221
Reputation: 10048
You can use p:defaultCommand
<p:defaultCommand target="btnId" />
Upvotes: 3
Reputation: 1964
You can catch the "press enter event" in JavaScript and simulate a click on the button of your choice.
Something like this :
$('#yourInput').on('keyup', function(e) {
if (e.which == 13) {
$("#yourButton").click();
}
});
Upvotes: 1