索引选项卡的 onTabClos​​e 事件

Index tab onTabClose event

如何获取接收到 onTabClos​​e 事件的选项卡的索引?

<p:tabView rendered="#{testBean.renderTab}" id="WorkSpace" onTabClose="var title = #{tab.title} ; console.log(title); // Not working return null ">
        <c:forEach items="#{testBean.tabs}" var="tab" varStatus="status">
        <p:tab title="#{tab.title}" closable="true" id="tab${status.count}" >
        <ui:include src="#{tab.composition}" />
        </p:tab>
        </c:forEach>
    </p:tabView>

谢谢。

primefaces 5.1 文档说明如下:

Tabview has three callbacks for client side. onTabChange is executed when an inactive tab is clicked, onTabShow is executed when an inactive tab becomes active to be shown and onTabClose when a closable tab is closed. All these callbacks receive index parameter as the index of tab.

所以要在客户端获取关闭标签的索引,您可以使用以下内容:

<p:tabView ... onTabClose="console.log(index);">
    ...
</p:tabView>