Using JQuery with Nitro

30 Jan 2007

JQuery is my favourite javascript library. It is lean and mean, pragmatic and generally a joy to use. The nicely organized web site and tons of easy to follow tutorials help as well. Moreover, JQuery fits nicely in a Nitro web application. I use a simple Nitro Element to integrate JQuery code in my templates:

class JQuery 
  def render 
    %~ 
    <script type="text/javascript"> 
      $(function() { 
        #{content} 
      }); 
    </script> 
    ~ 
  end 
end 

And this is used like this:

<JQuery> 
  $('#clickme').click(function(e) { 
    $(this).toggle(); 
  }) 
</JQuery> 

... 

<div id="clickme">Hello</div> 

Simple and effective, don’t you think?


comments powered by Disqus