Chuck's Face

RSS

Rails Flash Notice, Case Closed

Syed Aslam has written a good post on adding a close button to your Rails Flash Notice Messages using Javascript. Well worth a read. Here is a short extract…

<% flash.each do |name, msg| %>
  <%= content_tag :div, :id => "flash_#{name}" do %>
    <%= msg %>
    <%= content_tag :span, :style => "float: right;" do %>
      <%= link_to_function image_tag('icons/cross.png'), 
	 :onclick => "document.getElementById('flash_#{name}').style.display='none'" %>
     <% end %>
  <% end %>
<% end %>