Target Enum List Values in Portal .js
I am trying to hide certain elements of a custom form when an Enum List equals a certain value.
<div>I have been using the below for Strings, but it does not work for Enum Lists.</div>if(pageForm.viewModel.UserInput2 == 'Full Time') {<br>//Choose the fields to hide<br>var endDateLabel = $(".form-group label[for='SRDate2']");<br>var endDateInput = endDateLabel.next();<br>endDateLabel.hide();<br>endDateInput.hide();
}
So far I have tried just using the property name, and below:
Anyone know how to reference Enum lists and their values? Cheers
var TrainingTarget = "3f711d2c-513a-a7bf-7c54-55f0829b3a8d" if(pageForm.viewModel.TrainingTarget == 'Individual Training') { //Choose the fields to hide var GrpLabel = $(".form-group label[for='SRString6']"); var GrpInput = GrpLabel.next(); GrpLabel.hide(); GrpInput.hide(); }
Best Answer
-
Geoff_Ross Cireson Consultant O.G.Chris,
An Enum is a JavaScript Object in the ViewModel so you need to reference a particular property of it.if(pageForm.viewModel.TrainingTarget.Name == 'Individual Training')
Or for multi language environmentsif(pageForm.viewModel.TrainingTarget.Id == '5cf234fc-b718-85dd-a8b3-bdaa92d8e89c')
Geoff5
Answers
An Enum is a JavaScript Object in the ViewModel so you need to reference a particular property of it.
Or for multi language environments
Geoff
<br>Thanks Geoff - Worked perfectly.