rails flash alert message will close only on sign in page -


i looking rest of app pages automatically close flash messages displayed. occurs on sign-in page correctly closes on own. rest of flash alerts shouldn't need closed click.

maybe interaction devise throwing off?

rails 4.x, ruby 2.x, devise

on application.html:

<body>    <%= render partial: 'layouts/navigation' %>    <% flash.each |name, msg| %>   <% if msg.is_a?(string) %>     <div class="row" style="max-width:500px;">       <div data-alert class="alert-box info round <%= name.to_s == 'notice' ? 'success' : 'alert' %>">         <h3><%= content_tag :div, msg %>         <a href="#" class="close">&times;</a></h3>       </div>     </div>   <% end %>   <% end %>    <%= yield %>   <%= javascript_include_tag "application" %>    </body> 

on application.js

$(document).ready(function () {   $(".alert").delay(1000).fadeout(3000); 

you fading out when there alert. when there flash or notice? either of those, fade out not happen because class not exist.

you set class based on type of message being shown.

<%= name.to_s == 'notice' ? 'success' : 'alert' %>   

so fade out when alert.

try surrounding entire thing in div class message.

<body>  <%= render partial: 'layouts/navigation' %>  <% flash.each |name, msg| %> <% if msg.is_a?(string) %>   <div class="row" style="max-width:500px;">     <div class="message">       <div data-alert class="alert-box info round <%= name.to_s == 'notice' ? 'success' : 'alert' %>">         <h3><%= content_tag :div, msg %>         <a href="#" class="close">&times;</a></h3>       </div>     </div>   </div> <% end %> 

then change javascript to:

$(document).ready(function () {   $(".message").delay(1000).fadeout(3000);   

this fade out class message , won't matter if stuff inside has class of alert, flash, or notice. same thing.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -