我想要显示的错误
flash[:error] = "Invalid username/password combination."
我试过
$(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);
});
没有成功..我已经包含了javascript文件
<%= javascript_include_tag 'jquery-1.3.2' %>
答案 0 :(得分:6)
您无法获取错误消息。
flash[:error] = "Invalid username/password combination."
只输出原始文本。
flash[:error] = "<div class='error'>Invalid username/password
combination.</div>"
将其包装在容器中。
然后您可以使用jQuery淡出容器。
$(".error").fadeOut(2000);