Dependent fields problem
Dependent fields problem
Hi!
I use the following code, and it's working:
editor1.dependent( 'option', function ( val )
{
return (val === 'value1' || val === 'value2') ?
{ show: ['field1', 'field2', 'field3'] }:
{ hide: ['field1', 'field2', 'field13'] };
} );
Is it possible to change the simple if statement to real if - else if - else statement or switch statement?
I tied this, but doesn't work:
editor1.dependent( 'option', function ( val )
{
if (val === 'value1' || val === 'value2')
{
show: ['field1', 'field2', 'field3'];
return true;
}
else
{
hide: ['field1', 'field2', 'field3'];
return false;
}
} );
I tried the following too, but doesn't work either:
editor1.dependent( 'option', function ( val )
{
switch(val)
{
case 'value1':
show: ['field1', 'field2', 'field3'];
hide: ['field4', 'field5', 'field6'];
return true;
break;
case 'value2':
show: ['field4', 'field5', 'field6'];
hide: ['field1', 'field2', 'field3'];
return true;
break;
}
} );
What is the correct syntax of this expression?
Thank You and best regards.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I haven't used dependent much but I think that you need to return the show/hide objects instead of true or false. Haven't tried it but I think this is what you want:
or
Kevin
Dear Kevin,
You are a real hero.
Thank You.