title: Load jquery opendialog asynchronously with ruby on rails using haml
body: <p>I'm working on a rails web app. In one of my views (at index.html.haml) I have a jquery opendialog where I list a few things.
  My problem is I don't want to load this when the index page is loaded but at the openclick event.
  I'll provide some of the code. I am still new to rails, haml and jquery so any help will be welcomed, thanks in advance.</p>
  
  <p>Regards.</p>
  
  <pre><code>#...stuff
  
  #dialog creation and loading
  .dialog{:id =&gt; "codes_#{stuff.id}", :title =&gt; t_s(:index, resource_class.to_s.downcase)}
    #dialog: haml code with the list loading that is done when the main page is loaded instead on being called at the onclick
  
  #link that opens the dialog
  = link_to t_s(:show, resource_class.to_s.downcase), '#', :onclick =&gt; "openDialog(#{stuff.id})", :title =&gt; t_s(:show, resource_class.to_s.downcase)+ " " +t_s(:index, resource_class.to_s.downcase)
  
  #...stuff
  </code></pre>
  
  <p>this is some of the generated js:</p>
  
  <pre><code>$(document).ready(function(){
   $(".dialog").dialog({ width: 600, height: 400, autoOpen: false, modal: true, show: "blind", hide: "explode"
   });
  }); 
  function openDialog(id){ 
  $("#codes_"+id).dialog( "open" ); return false; 
  }
  </code></pre>
  
  <p>Regards</p>