Nice flash messages that fade out.


/ Published in: Rails
Save to your folder(s)

put in application_helper


Copy this code and paste it in your HTML
  1. def show_flash(options={})
  2. options = {:fade => 1, :display => 2, :highlight => 3}.merge(options)
  3. html = content_tag(:div, flash.collect{ |key,msg| content_tag(:div, msg, :class => key, :attributes => "style = display: none;") }, :id => 'flash-message')
  4. html << content_tag(:script, "new Effect.Highlight('flash-message', {duration: #{options[:highlight]}});") if options[:highlight]
  5. html << content_tag(:script, "setTimeout(\"$('flash-message').fade({duration: #{options[:fade]}});\", #{options[:display]*1000}); return false;")
  6. end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.