Expand/Collapse all fieldsets nested in a tab of a tabview

UI Components for JSF
Post Reply
romalex
Posts: 2
Joined: 06 Jun 2011, 09:08

06 Jun 2011, 12:05

Hello,

is there a way to parse every fieldset nested inside a tab and expand/collapse it using javascript ?
Thank you very much.

Romalex.

romalex
Posts: 2
Joined: 06 Jun 2011, 09:08

13 Jun 2011, 08:54

Hi,

my own answer, if this can help :

Code: Select all

function expandAllFld(callerElement){
    var form = callerElement.form;
    var allFsets = form.getElementsByTagName('fieldset');
    var fset = null;
    var input = null;
    var span = null;
    var div = null;
    if (callerElement.checked){
        //Expand all fieldsets
         for (var i=0; i<allFsets.length; i++)
         {
             fset = allFsets[i];
             input = fset.getElementsByTagName('input');
             if (input[0].value == 'true') {
                 input[0].value = 'false';
                 div = fset.getElementsByTagName('div');
                 div[0].style.display = '';
                 span = fset.getElementsByTagName('span');
                 span[0].className = "ui-fieldset-toggler ui-icon ui-icon-minusthick";
             }
         }
    }
    else {
        //Collapse all fieldsets
        for (i=0; i<allFsets.length; i++)
         {
             fset = allFsets[i];
             input = fset.getElementsByTagName('input');
             if (input[0].value == 'false') {
                 input[0].value = 'true';
                 div = fset.getElementsByTagName('div');
                 div[0].style.display = 'none';
                 span = fset.getElementsByTagName('span');
                 span[0].className = "ui-fieldset-toggler ui-icon ui-icon-plusthick";
             }
         }
    }
}
Best regards.

Romalex

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

13 Jun 2011, 09:02

Fieldset also has simpler client side api method called widgetVar.toggle().

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 33 guests