auto hide the flash messages in rails
This should work for you. You can specify the time span within the brackets. Add this to your Javascript. this is common for all:
$(".alert" ).fadeOut(3000);
For alert success:
$(".alert-success" ).fadeOut(3000);
For alert danger:
$(".alert-danger" ).fadeOut(3000);
This one will work with Turbolinks-3.
$(document).on('page:change', function(){
$(".alert").delay(2000).slideUp(500, function(){
$(".alert").alert('close');
});
});
Turbolinks 5:
$(document).on('turbolinks:load', function(){
$(".alert").delay(2000).slideUp(500, function(){
$(".alert").alert('close');
});
});
try:
<%= simple_form_for(@dashboard_user) do |f| %>
<% if @dashboard_user.errors.any? %>
<span class="error_msgs">
<ul class="alert alert-danger">
<% for message_error in @dashboard_user.errors.full_messages %>
<li>
<%= message_error %>
</li>
<% end %>
</ul>
</span>
<script>
setTimeout("$('.error_msgs').fadeOut('slow')", 5000)
</script>
<% end %>
this will fade out your flash after 5000ms.