iCoreTech Research Labs Just a placeholder

19Aug/091

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

Related posts:

  1. i18n URL-based breadcrumbs in Rails
  2. Reminder: empty email subjects in Snow Leopard server’s postfix
  3. Rails users < membership > groups? Enter Workflow
  4. Send SMS with Ruby on Rails
  5. Rails vs. Tarantula

Comments (1) Trackbacks (0)
  1. Nice blog. Thanks for the code – very handy.


Leave a comment


No trackbacks yet.

Additional comments powered by BackType