# Using replace\_html and fade with rjs

**URL:** <https://www.ruby-forum.com/t/using-replace-html-and-fade-with-rjs/154091>\
**Category:** Rails\
**Created:** [November 25, 2008, 9:48am UTC](https://www.ruby-forum.com/t/using-replace-html-and-fade-with-rjs/154091 "2008-11-25T09:48:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [November 25, 2008, 9:48am UTC](https://www.ruby-forum.com/t/using-replace-html-and-fade-with-rjs/154091/1 "2008-11-25T09:48:47Z")

</div>

I have run into a problem using replace\_html and fade together to  
display an error message. The error message is displayed when a user  
enters the wrong username or password and then fades away. The  
problem is that if a user enters incorrectly again, the error is not  
displayed again. I need someway of resetting the html element so that  
I can replace it again. Here is the relevant code:

format.js do  
render :update do |page|  
page.form.reset ‘login\_form’  
page.visual\_effect(:fade, “login\_error”, :duration =\> 2)  
page.replace\_html ‘login\_error’, “Username and password do not  
match.”  
end  
end

any ideas?

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [November 25, 2008, 10:31am UTC](https://www.ruby-forum.com/t/using-replace-html-and-fade-with-rjs/154091/2 "2008-11-25T10:31:35Z")

</div>

On 25 Nov 2008, at 08:47, David wrote:

> I have run into a problem using replace\_html and fade together to  
> display an error message. The error message is displayed when a user  
> enters the wrong username or password and then fades away. The  
> problem is that if a user enters incorrectly again, the error is not  
> displayed again. I need someway of resetting the html element so that  
> I can replace it again. Here is the relevant code:

fading eventually marks the corresponding dom element as invisible.  
You’ll need to show it again (page.show etc…)

Fred
