Hide multiple tabs

rss

Posted by Gregory Murillo - Jun 17 ’15 at 04:44

Hi there,

I need to hide more than one tab at the time based in a condition. Here is the code:

var title1 = fd.field('SurveyName').value();

var title2 = fd.field('SurveyName2').value();

var title3 = fd.field('SurveyName3').value();

var title4 = fd.field('SurveyName4').value();

var title5 = fd.field('SurveyName5').value();

var title6 = fd.field('SurveyName6').value();

var title7 = fd.field('SurveyName7').value();

/*Now we need to validate to hide / show tabs*/

if(title1==""){

alert('Title1 Vacio');

$('#fd_tabcontrol-0').tabs('option', 'disabled', [0]);

}

if(title2==""){

alert('Title2 Vacio');

$('#fd_tabcontrol-0').tabs('option', 'disabled', [1]);

}

if(title3==""){

alert('Title3 Vacio');

$('#fd_tabcontrol-0').tabs('option', 'disabled', [2]);

}

if(title4==""){

alert('Title4 Vacio');

$('#fd_tabcontrol-0').tabs('option', 'disabled', [3]);

}

if(title5==""){

alert('Title5 Vacio');

$('#fd_tabcontrol-0').tabs('option', 'disabled', [4]);

}

if(title6==""){

alert('Title6 Vacio');

$('#fd_tabcontrol-0').tabs('option', 'disabled', [5]);

}

if(title7==""){

alert('Title7 Vacio');

$('#fd_tabcontrol-0').tabs('option', 'disabled', [6]);

}

It is only disabling tab [#6], and should hide tabs 2, 3, 4, 5 and 6

Thanks.

 

  • rostislav
    rostislav
    Moderator
    Member for: 4 years 1 month 13 days
    #1 by rostislav Jun 18 ’15 at 06:07

    Try something like this:

    var title1 = fd.field('SurveyName').value();
    var title2 = fd.field('SurveyName2').value();
    var title3 = fd.field('SurveyName3').value();
    .... etc
    
    var tabsToDisable = [];
    if(title1==""){
    alert('Title1 Vacio');
    tabsToDisable.push(0);
    }
    if(title2==""){
    alert('Title2 Vacio');
    tabsToDisable.push(1);
    }
    if(title3==""){
    alert('Title3 Vacio');
    tabsToDisable.push(2);
    }
    .....etc
    
    $('#fd_tabcontrol-0').tabs('option', 'disabled', tabsToDisable);
    

    Note that when you disable one or more tabs, all other tabs in the control are enabled. That was your problem, each time you disabled one tab, you enabled all the others.

Displaying 1 to 1 of 1 messages