jGrowl on Rails (with i18n)

Install JQuery and jGrowl plugin.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  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
$1.99 domains with SSL purchase!

One thought on “jGrowl on Rails (with i18n)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">