title: How to use a foreach loop with an ILIST<models> in javascript?
body: <p>Hi I have a razor view  in my MVC 3 application using a <code>@model IList&lt;TrackerModel&gt;</code></p>
  
  <p><code>IList&lt;TrackerModel&gt;</code> is being passed to the view from a action method in my controller.
  As the name suggests it's a list of <code>TrackerModels</code>.</p>
  
  <p>I want to pass this list the the javascript block at the bottom of my view.</p>
  
  <p>Run the list through a foreach loop so that each model makes use of a certain function.
  eg.</p>
  
  <pre><code>foreach(var mod in IList&lt;TrackerModel&gt;)
  {
       LoadAttachments();
  }
  </code></pre>
  
  <p>(I know the above is wrong, but you get the idea)
  Can this be done ?</p>
  
  <pre><code>   @foreach(var mod in Model)
  {
      LoadAttachments(@Newtonsoft.Json.JsonConvert.SerializeObject(mod));
  }
  </code></pre>
  
  <p>tried the above suggestion , and got the following errors.
  @foreach = condition compilation is turned off ?</p>
  
  <p>var = Expected expression ?</p>
  
  <p>in = expected ; ?</p>
  
  <p>LoadAttachments = the name 'LoadAttachments ' does not exist in the current context ?</p>
  
  <p>@Newtonsoft = condition compilation is turned off ?</p>