jGrowl in Rails for flash 1
Install JQuery and jGrowl plugin. Also include I18n.
def display_flash
flash_types = [:error, :warning, :notice]
messages = ((flash_types & flash.keys).collect do |key|
"$.jGrowl('#{flash[key]}', { header: '#{I18n.t(key, :default => key.to_s)}', theme: '#{key.to_s}'});"
end.join("\n"))
if messages.size > 0
content_tag(:script, :type => "text/javascript") do
"$(document).ready(function() { #{messages} });"
end
else
""
end
end
Trackbacks
Use the following link to trackback from your own site:
http://www.icoretech.org/trackbacks?article_id=jgrowl-in-rails-for-flash&day=13&month=09&year=2008
Comments
-
Thanks, I was just about to write something like this - glad I spent 10 seconds in Google before I did. Worked perfectly!