0

Trying to access the wrapper class variable in javascript, but it's not serialized in apex controller. trying to get the value in for loop - mainly for validation purpose.

function validateApplicantInfo(thisvar, AddFields){

  /* Result from AddFields
   [MFF_Fields:[MFF_DateFldvalue=null, MFF_DepFldList=(), 
   MFF_DepPicklistOpts=null, MFF_FieldLabel=Account Name, MFF_FieldName=Name, 
   MFF_FieldOrderNum=0, MFF_FieldType=String, MFF_FieldValue=null....

   Need to loop through the wrapper class variables */

    var records = [];
    records = AddFields.MFF_Fields;
    for(var i = 0;  i< records.size; i++){

       if($("[id$='stringFld']").val() == '' && records[i].MFF_RequiredField == true){
          $("[id$='stringFld']").parent().addClass('slds-has-error');
          isError = true;
        }
     }

PS- Wrapper object is not serialized in apex controller

1 Answer 1

1

Since it's a global wrapper list you can access it directly in JavaScript. Use <apex:repeat> function in script to loop through the List.

function validateApplicantInfo(thisvar){

  <apex:repeat value="{!MFAddEditFields}" var="local">  
    if($("[id$='stringFld']").val() == '' && {!local.MFF_RequiredField}' == true){  
       $("[id$='stringFld').parent().addClass('slds-has-error');
          isError = true;
       }
  </apex:repeat> 
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .