<% params[:name] ||= 'looking_for_window' %> var window_id = "<%= params[:name] %>"; <% params[:assignments].each do |key, value| %> $("#<%= key %>").val("<%= value %>"); <% end %> $("#"+window_id).dialog('close');