Posted By

insanedreamer on 07/23/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

NARKOZ


Nice flash messages that fade out.


 / Published in: Rails
 

put in application_helper

  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  

You need to login to post a comment.