i am exploring the tab components in primefaces http://www.primefaces.org/showcase/ui/tabviewChangeListener.jsf , and i was wondering if it's possible to invoke a JavaScript when a specific tab is being clicked.
please advise, thanks.
There are two ways to hook up on tab change events:
Use onTabChange attribute of <p:tabView> tag to execute a callback function on the appropriate event:
<p:tabView onTabChange="handleTabChange(index)">
//tabs
</p:tabView>
Use oncomplete attribute of <p:ajax> tag to execute a JS function when AJAX call completes successfully:
<p:ajax event="tabChange" listener="#{tabBean.onTabChange}" oncomplete="handleOncomplete(xhr, status, args)"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With