Im using the following code to hide sections that are not required based on the multi selection in the 'AreasAffected' field:
fd.field('AreasAffected').$on('change', function (props) {
$(fd.field('AE_HSE').$parent.$el).hide();
$(fd.field('AE_Facility').$parent.$el).hide();
$(fd.field('AE_Drilling').$parent.$el).hide();
$(fd.field('AE_Wells').$parent.$el).hide();
$(fd.field('AE_Ops').$parent.$el).hide();
for (var i = 0; i < props.length; i++) {
//show fields if the option is selected
switch (props[i]) {
case 'HSE':
$(fd.field('AE_HSE').$parent.$el).show();
break;
case 'Facility':
$(fd.field('AE_Facility').$parent.$el).show();
break;
case 'Drilling':
$(fd.field('AE_Drilling').$parent.$el).show();
break;
case 'Wells':
$(fd.field('AE_Wells').$parent.$el).show();
case 'Operations':
$(fd.field('AE_Ops').$parent.$el).show();
}
}
});
Code works well, I just need it to apply/refresh when the page loads on the 'edit' view, as it doesn't hide/show the selected values until something changes (which I understand is due to the $on('change' function), just can't work out how to trigger it on page load to initially apply.