I have problem with close button on tab.
when tab is added, button is visible, but when content is loaded button is disappear?
Code: Select all
function addTab(tabManager, href , label, index) {
var tabExists = false;
var $tabs = jQuery(tabManager.jqId).tabs({
tabTemplate: '<li><a href="#{href}">#{label}</a> <span class="ui-icon ui-icon-close">Remove Tab</span></li>',
add: function(event, ui) {
$(this).tabs('select',ui.index);
},
closable:true
});
jQuery(tabManager.jqId+' span.ui-icon-close' ).live( 'click',
function() {
var index = jQuery( 'li', $tabs ).index( jQuery( this ).parent() );
if(index != -1)
$tabs.tabs( 'remove', index );
}
);
jQuery(tabManager.jqId+' ul li a').each(function(i) {
if (this.text == label) {
tabExists = true;
index = i;
}
});
if(tabExists) {
$tabs.tabs('select', index);
} else {
$tabs.tabs('add', '#'+href, label);
}
alert("stop ...")
return true;
}
index.xhtml
Code: Select all
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<p:growl id="messages"/>
<ui:composition template="resources/templates/template.xhtml">
<ui:define name="content">
<h:form prependId="false">
<h:panelGroup layout="block" styleClass="menu">
<ui:include src="resources/templates/menu.xhtml"/>
</h:panelGroup>
<p:tabView styleClass="main_tabView" id="tabNav" widgetVar="tabNav" >
<p:tab title="albums" id="albums" rendered="#{menuBacking.albums}">
<ui:include src="/pages/albums.xhtml"/>
</p:tab>
<p:tab title="band" id="band" rendered="#{menuBacking.band}">
<ui:include src="/pages/band.xhtml"/>
</p:tab>
<p:tab title="concerts" id="concerts" rendered="#{menuBacking.concerts}">
<ui:include src="/pages/concerts.xhtml"/>
</p:tab>
<p:tab title="contacts" id="contacts" rendered="#{menuBacking.contacts}">
<ui:include src="/pages/contacts.xhtml"/>
</p:tab>
</p:tabView>
</h:form>
</ui:define>
</ui:composition>
</html>