pa:tab onHide event
Forum rules
Please note that response time for technical support is within 3-5 business days.
Please note that response time for technical support is within 3-5 business days.
-
- Posts: 5281
- Joined: 29 Jun 2013, 12:38
I think onTabChange might be better. I added it to next version. For now, please make the following changes;
primefaces-barcelona.taglib.xml
TabMenu.java
TabMenuRenderer.java
layout.js
primefaces-barcelona.taglib.xml
Code: Select all
//line 135
<attribute>
<name>onTabChange</name>
<required>false</required>
<type>java.lang.String</type>
<description>Client side callback to execute when a tab is clicked.</description>
</attribute>
Code: Select all
//line 24
public enum PropertyKeys {
widgetVar,
activeIndex,
onTabChange;
...
//line 68
public java.lang.String getOnTabChange() {
return (java.lang.String) getStateHelper().eval(PropertyKeys.onTabChange, null);
}
public void setOnTabChange(java.lang.String _onTabChange) {
getStateHelper().put(PropertyKeys.onTabChange, _onTabChange);
}
Code: Select all
//line 113
WidgetBuilder wb = getWidgetBuilder(context);
wb.init("Barcelona", tabMenu.resolveWidgetVar(), clientId)
.callback("onTabChange", "function(index)", tabMenu.getOnTabChange());
wb.finish();
Code: Select all
//line 60
this.tabMenuNavLinks.on('click', function(e) {
$this.sidebar.css('overflow','hidden');
setTimeout(function() {
$this.sidebar.css('overflow','');
}, 301);
var link = $(this),
index = link.parent().index();
//Call user onTabChange callback
if($this.cfg.onTabChange) {
var result = $this.cfg.onTabChange.call($this, index);
if(result === false)
return false;
}
link.parent().addClass('active-item').siblings('.active-item').removeClass('active-item');
...
Github Profile: https://github.com/mertsincan
-
- Posts: 5281
- Joined: 29 Jun 2013, 12:38
Exp;
Code: Select all
...
<pa:tabMenu onTabChange="return test(index)">
...
<script type="text/javascript">
function test(index) {
console.log(index);
if(index%2===0) {
return true;
}
else {
return false;
}
}
</script>
Github Profile: https://github.com/mertsincan
-
- Posts: 5281
- Joined: 29 Jun 2013, 12:38
How do you hide pa:tab? using menu-button icon that is in layout-submenu-title or by clicking on the other tabs. Which menu mode are you using?
Github Profile: https://github.com/mertsincan
-
- Posts: 5281
- Joined: 29 Jun 2013, 12:38
Ok, thanks a lot for the update! I'll work on it and get back to you.
Github Profile: https://github.com/mertsincan
-
- Posts: 5281
- Joined: 29 Jun 2013, 12:38
I added onTabChange and onTabClose callbacks to next version. For now, please make the following changes;
primefaces-barcelona.taglib.xml
TabMenu.java
TabMenuRenderer.java
layout.js
primefaces-barcelona.taglib.xml
Code: Select all
//line 135
<attribute>
<name>onTabChange</name>
<required>false</required>
<type>java.lang.String</type>
<description>Client side callback to execute when a tab is clicked.</description>
</attribute>
<attribute>
<name>onTabClose</name>
<required>false</required>
<type>java.lang.String</type>
<description>Client side callback to execute before a tab is closed. Return false to prevent closing.</description>
</attribute>
Code: Select all
//line 24
public enum PropertyKeys {
widgetVar,
activeIndex,
onTabChange,
onTabClose;
...
//line 68
public java.lang.String getOnTabChange() {
return (java.lang.String) getStateHelper().eval(PropertyKeys.onTabChange, null);
}
public void setOnTabChange(java.lang.String _onTabChange) {
getStateHelper().put(PropertyKeys.onTabChange, _onTabChange);
}
public java.lang.String getOnTabClose() {
return (java.lang.String) getStateHelper().eval(PropertyKeys.onTabClose, null);
}
public void setOnTabClose(java.lang.String _onTabClose) {
getStateHelper().put(PropertyKeys.onTabClose, _onTabClose);
}
Code: Select all
//line 113
WidgetBuilder wb = getWidgetBuilder(context);
wb.init("Barcelona", tabMenu.resolveWidgetVar(), clientId)
.callback("onTabChange", "function(index)", tabMenu.getOnTabChange())
.callback("onTabClose", "function(index)", tabMenu.getOnTabClose());
wb.finish();
Code: Select all
//line 37
this.tabMenu.find('.menu-button').on('click', function(e) {
//Call user onTabClose callback
if($this.cfg.onTabClose) {
var index = $this.tabMenuNav.find('.active-item').index(),
result = $this.cfg.onTabClose.call($this, index);
if(result === false)
return false;
}
$this.wrapper.removeClass('layout-wrapper-menu-active');
...
//line 60
this.tabMenuNavLinks.on('click', function(e) {
$this.sidebar.css('overflow','hidden');
setTimeout(function() {
$this.sidebar.css('overflow','');
}, 301);
var link = $(this),
index = link.parent().index();
//Call user onTabChange callback
if($this.cfg.onTabChange) {
var result = $this.cfg.onTabChange.call($this, index);
if(result === false)
return false;
}
link.parent().addClass('active-item').siblings('.active-item').removeClass('active-item');
...
//line 234
$(document.body).on('click', function() {
if(!$this.topbarMenuClick && !$this.topbarLinkClick) {
$this.topbarItems.filter('.active-topmenuitem').removeClass('active-topmenuitem');
$this.topbarMenu.removeClass('topbar-menu-visible');
}
if(!$this.sidebarClick && ($this.isOverlayMenu() || !$this.isDesktop())) {
//Call user onTabClose callback
if($this.cfg.onTabClose) {
var index = $this.tabMenuNav.find('.active-item').index(),
result = $this.cfg.onTabClose.call($this, index);
if(result === false)
return false;
}
$this.wrapper.removeClass('layout-wrapper-menu-active');
}
...
Github Profile: https://github.com/mertsincan
-
- Information
-
Who is online
Users browsing this forum: No registered users and 7 guests