Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i get my error messages to fade out? in RubyOnRails 3

The error i want to show

flash[:error] = "Invalid username/password combination."

I've tried

$(document).ready( function() {// When the Dom is ready
    $('.error').hide();//Hide the div
    $('.alert').hide();
    $('.notice').hide();
    $('.success').hide();
    $('.info').hide();

    $(".error").fadeOut(2000); //Add a fade out effect that will last for 2000 millisecond
    $(".alert").fadeOut(2000);
    $(".notice").fadeOut(2000);
    $(".success").fadeOut(2000);
    $(".info").fadeOut(2000);

});

with no success.. I have included the javascript file

<%= javascript_include_tag 'jquery-1.3.2' %>
like image 714
ahmet Avatar asked Jul 14 '11 15:07

ahmet


1 Answers

You don't have a way to get the error message.

flash[:error] = "Invalid username/password combination."

just outputs raw text.

 flash[:error] = "<div class='error'>Invalid username/password
 combination.</div>"

wraps it in a container.

then you can just use jQuery to fade the container out.

$(".error").fadeOut(2000); 
like image 89
Bobby Borszich Avatar answered Oct 03 '22 07:10

Bobby Borszich