3

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.

4

1 回答 1

6

有两种方法可以连接选项卡更改事件:

  1. 使用标签的onTabChange属性<p:tabView>对相应的事件执行回调函数:

    <p:tabView onTabChange="handleTabChange(index)">
    //tabs
    </p:tabView>
    
  2. 当 AJAX 调用成功完成时,使用标签的oncomplete属性<p:ajax>执行 JS 函数:

            <p:ajax event="tabChange" listener="#{tabBean.onTabChange}" oncomplete="handleOncomplete(xhr, status, args)"/>
    
于 2013-04-28T13:49:40.643 回答