acts_as_dismissible icon indicating copy to clipboard operation
acts_as_dismissible copied to clipboard

Allows you to create messages in the user interface, which the users can dismiss once read. The plugin stores the reference to the dismissed message in a cookie.

= Acts As Dismissible

Allows you to create messages in the user interface, which the users can dismiss once read. The plugin stores the reference to the dismissed message in a cookie.

= Usage Examples

Add a dismissible message to the view:

<% dismissible_message('site_welcome') do -%>

Hello and welcome to our site. I hope you enjoy your stay. Feel free to look around.

Produces:

Hello and welcome to our site. I hope you enjoy your stay. Feel free to look around.

Don't show this again.

Add A custom message

<% dismissible_message('site_welcome', { :message => "Do not show this again" }) do -%>

Hello and welcome to our site. I hope you enjoy your stay. Feel free to look around.

Only display this message if a previous dismissible message was dismissed.

<% dismissible_message('cookie_two', { :message => "Do not show this again", :follows => "cookie_one" }) do -%>

Why did you dismiss the last message?

Use your own dismiss text or button, and/or specify a callback to execute after the cookie has been set.

<%- dismissible_message('welcome_message', :dismiss_button => 'dismiss_welcome', :callback => 'Effect.BlindUp') do -%>

Hide me!

Hide
<script type="text/javascript" charset="utf-8">
  $('dismiss_welcome').observe('click', function(event){
    dismiss_window_hide_dismissible_welcome_message();
  });
</script>

<%- end ->

= Authors

Mark Daggett

= Extra Credit

The cookie implementation for this plugin is based off ideas from Court3 and DanP. Rick Olson also helped clean up some of this code to make it more succinct.