Skip to main content
Nintex Community Menu Bar
Question

jquery $.each syntax check?

  • July 9, 2024
  • 2 replies
  • 6 views

Forum|alt.badge.img+18

Can someone give me a quick thumbs up/down on my syntax?

var $ = skuid.$;<br>var mSTD = skuid.$M('STDTest');<br><br>$.each(mSTD, function(i, row){ <br> value += row.STD__c + ' (' + row.Results__c + ') '; });


If my model STDTest has two rows:
Row 0 has STD__c: HSV1, Results: Negative
Row 1 has STD__c: HIV, Results: Positive

I’m trying to produce a text variable ‘value’ that would look like:
'HSV1 (Negative) HIV (Positive) '

Am I understanding the way $.each works?

This topic has been closed for replies.

2 replies

Forum|alt.badge.img+8
  • 649 replies
  • July 9, 2024

Your mSTD variable is a reference to the model object.  So your code as is would iterate over the properties of the model.  This is most likely not your intention.  You should iterate over mSTD.data instead.

$.each(mSTD.data, function(i, row){<br>&nbsp; &nbsp; value += row.STD__c + ' (' + row.Results__c + ') ';<br>});

Forum|alt.badge.img+18
  • Author
  • 2192 replies
  • July 9, 2024

Thanks, Ben!