title: Can I call a jquery or javascript function in grails g:each element?
body: <p>I want to call a jquery function in grails g:each element, i'm using a function call  on page load to filter a table which has a loop as follows</p>
  
  <pre><code>   &lt;g:each in="${sampleTypes}" status="i" var="sampleType"&gt;
  &lt;div class="uniq"&gt;${sampleType}&lt;/div&gt;
  &lt;table id="sampleTable"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th class="no-sort"&gt;&lt;g:message code="labWorkItem.testUnit.label"
                      default="CustomerId" /&gt;&lt;/th&gt;
  
              &lt;th class="no-sort"&gt;&lt;g:message code="labWorkItem.testUnit.label"
                      default="OrderNo" /&gt;&lt;/th&gt;
              &lt;th class="no-sort"&gt;&lt;g:message code="labWorkItem.testUnit.label"
                      default="DateCreated" /&gt;&lt;/th&gt;
              &lt;th class="no-sort"&gt;&lt;g:message code="labWorkItem.testUnit.label"
                      default="Test unit" /&gt;&lt;/th&gt;
  
              &lt;th class="no-sort no-visible"&gt;&lt;g:message
                      code="labWorkItem.sampleType.label" default="Sample Type" /&gt;&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;g:each in="${labWorkItemInstance}" status="a" var="labWorkItem"&gt;
              &lt;tr class="${(a % 2) == 0 ? 'even' : 'odd'}"&gt;
                  &lt;td&gt;
                      ${labWorkItem?.order?.customer?.customerId}
                  &lt;/td&gt;
                  &lt;td&gt;
                      ${labWorkItem?.order?.orderNo}
                  &lt;/td&gt;
                  &lt;td&gt;
                      ${labWorkItem?.order?.dateCreated}
                  &lt;/td&gt;
                  &lt;td &gt;
                      ${labWorkItem?.testUnit}
                  &lt;/td&gt;
                  &lt;td id = "labSample"&gt;
                      ${labWorkItem?.testUnit?.sampleType}
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/g:each&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;g:textField name="singleValue" value="Blood" id="someHiddenField"/&gt;
  &lt;/g:each&gt;
  </code></pre>
  
  <p>i am using the class "uniq" to filter the table</p>
  
  <pre><code>function typeSampleCollected() {
  jQuery.fn.dataTableExt.afnFiltering.push(function(oSettings, aData,
          iDataIndex) {
      if (oSettings.nTable.id != "sampleTable") {
          return true;
      }
  
          var uniq = jQuery("div.uniq").html();
  alert(uniq);
       jQuery("#someHiddenField").val(uniq);
       var someHiddenField = jQuery("#someHiddenField").val()
      if(someHiddenField){
          //var sampleValue = jQuery("#someHiddenField").val();
          //alert(sampleValue.toString());
      if (someHiddenField != aData[4]){
          console.log("sampleType"+someHiddenField);
          console.log("aData"+aData[4]);
          return false;
          }
      }
      else{
          console.log("else condition");
          }
      return true;
  });
  }
  </code></pre>
  
  <p>The problem is, it executes at the first on page load, only the first data of the loop executed others remains the same, i want the remaining data  also to execute.</p>