Primefaces PanelMenu accordion behavior

UI Components for JSF
sakkie6yster
Posts: 80
Joined: 23 Nov 2011, 08:46

04 Aug 2016, 20:20

hi tlog, I got a panel menu working 100% in Primefaces 5.3. :)
Primefaces 5.3, Extensions 4.0.0
Glassfish 3.1.2.2, Wildfly-10.0.0.Final
JSF 2.2

sakkie6yster
Posts: 80
Joined: 23 Nov 2011, 08:46

07 Aug 2018, 07:05

I'm experiencing the same problem trying to upgrade our application from 5.3 to 6.0.
Is there a way to implement this in a way that the panelMenu's "accordion behaviour" will not break with every new release?
Primefaces 5.3, Extensions 4.0.0
Glassfish 3.1.2.2, Wildfly-10.0.0.Final
JSF 2.2

kukeltje
Expert Member
Posts: 9199
Joined: 17 Jun 2010, 13:34
Location: Netherlands

07 Aug 2018, 09:49

it does not break with every new release. And maybe file an issue for an enhancement in PF... If you include a good Pull request, that will help
Ronald van Kuijk
______________________________
PrimeFaces 6.1, PrimeFaces plus 0.0.2 | JbossWildfly 10.1| Mojarra 2.2.13
Fedora 61, Firefox 'most recent'
Read the forum posting rules
Beginners: https://jsf.zeef.com/bauke.scholtz

sakkie6yster
Posts: 80
Joined: 23 Nov 2011, 08:46

07 Aug 2018, 11:06

Hi Kukeltje,

Thank you for your response.
What do you mean with "Good Pull Request"?
Primefaces 5.3, Extensions 4.0.0
Glassfish 3.1.2.2, Wildfly-10.0.0.Final
JSF 2.2

kukeltje
Expert Member
Posts: 9199
Joined: 17 Jun 2010, 13:34
Location: Netherlands

07 Aug 2018, 13:40

A pull request that does not break any other functionality
Ronald van Kuijk
______________________________
PrimeFaces 6.1, PrimeFaces plus 0.0.2 | JbossWildfly 10.1| Mojarra 2.2.13
Fedora 61, Firefox 'most recent'
Read the forum posting rules
Beginners: https://jsf.zeef.com/bauke.scholtz

sakkie6yster
Posts: 80
Joined: 23 Nov 2011, 08:46

13 Aug 2018, 07:04

I migrated our application from 5.3 to 6.2 and was able to resolve the JavaScript error by encompassing it with the JQuery "$(document).ready.." tags:

Code that broke:

Code: Select all

		PF('hbPanelMenu').headers.click(function() {
		    var currHeader = $(this);

		    PF('hbPanelMenu').headers.each(function() {
		        var header = $(this);
		        if (header.text() !== currHeader.text()) {
		        	PF('hbPanelMenu').collapseRootSubmenu(header);
		            header.removeClass('ui-state-hover');
		        }
		    });
		});
Fixed it with:

Code: Select all

$(document).ready(function () {       
		/*
		 *  Function adds accordion behaviour to the PrimeFaces PanelMenu:
		 *  It collapses other menu headers on the selection of a menu header 
		 * */
		PF('hbPanelMenu').headers.click(function() {
		    var currHeader = $(this);

		    PF('hbPanelMenu').headers.each(function() {
		        var header = $(this);
		        if (header.text() !== currHeader.text()) {
		        	PF('hbPanelMenu').collapseRootSubmenu(header);
		            header.removeClass('ui-state-hover');
		        }
		    });
		});		
});	
Primefaces 5.3, Extensions 4.0.0
Glassfish 3.1.2.2, Wildfly-10.0.0.Final
JSF 2.2

kukeltje
Expert Member
Posts: 9199
Joined: 17 Jun 2010, 13:34
Location: Netherlands

13 Aug 2018, 11:23

Thanks for reporting back!
Ronald van Kuijk
______________________________
PrimeFaces 6.1, PrimeFaces plus 0.0.2 | JbossWildfly 10.1| Mojarra 2.2.13
Fedora 61, Firefox 'most recent'
Read the forum posting rules
Beginners: https://jsf.zeef.com/bauke.scholtz

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: newbie2911 and 5 guests