开发者

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

开发者 https://www.devze.com 2023-03-20 13:33 出处:网络
The error i want to show flash[:error] = \"Invalid username/password combination.\" I\'ve tried $(document).ready( function() {// When the Dom is ready

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").fadeOu开发者_JS百科t(2000);
    $(".info").fadeOut(2000);

});

with no success.. I have included the javascript file

<%= javascript_include_tag 'jquery-1.3.2' %>


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); 
0

精彩评论

暂无评论...
验证码 换一张
取 消