title: Real time JavaScript to razor pages in MVC3
body: <p>Imagine some javascript codes will be add razor pages.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(function () {
          $('#photogallery a.lightbox').lightBox();
          $('#photogallery').infiniteCarousel({ imagePath: '/Content/Images/Components/InfiniteCarousel/', autoStart: false });
          $(".flows").collapsiblePanel();
          $(".tab@Model.id").tabs();
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>This code need some html element defined css class by  .tab and .flows.
  There is no sense for flows but .tab@model.id build in run time -because it need model-.</p>
  
  <p>I would like define an attribute for controller method and I would like to add automaticaly with code. </p>
  
  <p>How</p>
  
  <pre><code>[JavaScript("menu.js")]
  public ActionResult Menu(object param)
  {
   return PartialView(this.categoryService.GetAllCategories()[0]);
  }
  </code></pre>
  
  <p>and razor view will have automaticaly produced code with             </p>
  
  <pre><code>...
  $(".tab@Model.id").tabs(); 
  ...
  </code></pre>
  
  <p>Is it phantasy or could be implemented in real life.</p>
  
  <p>Thanks</p>