Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: How do I display flash[:notice] modally

I'm looking for a way to recreate the effect used by stackoverflow to display information about badges awarded etc to users, except I want to use the effect to display my flash messages.

In case it's not clear, I'm talking about the way site updates appear at the top of the browser window and stack there until the user clicks the X button although I won't mind if the messages disappear when the user refreshes the page.

I know this is not technically 'modal'.

Does anyone have any experience of doing this in rails?

like image 894
stephenmurdoch Avatar asked Sep 02 '25 04:09

stephenmurdoch


1 Answers

use this in your view

<%= render :partial => 'my_custom_flash', :flash => flash %>

and in _my_custom_flash.html.erb

<div id='flash-notice'><%= flash[:notice] %> <%= link_to_function 'Close', visual_effect(:fade, 'flash-notice' %></div>

and you have to set your CSS to make #flash-notice position absolute, with parameters like top:0 and width:100% to make it appear on the top.

I didn't test this code, but it would be my initial approach to solve this

like image 144
vrsmn Avatar answered Sep 05 '25 01:09

vrsmn