Simple Tooltip with Ruby on Rails

1st Step

add this code in app/helpers/application_helper.rb

def tooltip(content, options = {}, html_options = {}, *parameters_for_method_reference)
html_options[:title] = options[:tooltip]
html_options[:class] = html_options[:class] || ‘tooltip’
content_tag(“span”, content, html_options)
end

2nd Step

add code in app/views/foo/page.rhtml

3rd Step

add stylesheet in public/stylesheets/yourstyle.css

.mytooltip {
cursor: help;
color: green;
border-bottom: 1px dotted green
}
Originally

http://rafael.adm.br/p/simple-tooltip-helper-for-ruby-on-rails/

Advertisements