Page 1 of 1

Hide multiple tabs

Posted: 17 Jun 2015
by Gregory Murillo
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.

Re: Hide multiple tabs

Posted: 18 Jun 2015
by rostislav
Try something like this:

Code: Select all

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.