# How to eliminate replace\_html alert pop-up in RJS

**URL:** <https://www.ruby-forum.com/t/how-to-eliminate-replace-html-alert-pop-up-in-rjs/164523>\
**Category:** Rails\
**Created:** [April 2, 2009, 8:16am UTC](https://www.ruby-forum.com/t/how-to-eliminate-replace-html-alert-pop-up-in-rjs/164523 "2009-04-02T08:16:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkbeili](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7bcc69/32.png) [@tkbeili](https://www.ruby-forum.com/u/tkbeili)\
**Post date:** [April 2, 2009, 8:16am UTC](https://www.ruby-forum.com/t/how-to-eliminate-replace-html-alert-pop-up-in-rjs/164523/1 "2009-04-02T08:16:30Z")

</div>

Hello,

I’m using RJS for AJAX call. Something like:

page[“edit\_single\_client\_div” + params[“client\_id”]].replace\_html  
:partial =\> ‘client\_single\_display’, :locals =\> {:the\_client =\>  
SmsClient.valid.find\_by\_id(params[:client\_id]), :recipients\_session\_id  
=\> params[:recipient\_session\_id]}

it works fine but sometimes the DIV doesn’t exist on the page because  
the user has paginated that piece of the page. the replace\_html displays  
Alert about that. I want to keep silent and just ignore the fact that  
the DIV doesn’t exist on page anymore.

Any ideas how to do that?

Thanks,

Tam

---

<div class="post-metadata">

**Author:** ![tkbeili](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7bcc69/32.png) [@tkbeili](https://www.ruby-forum.com/u/tkbeili)\
**Post date:** [April 2, 2009, 8:47am UTC](https://www.ruby-forum.com/t/how-to-eliminate-replace-html-alert-pop-up-in-rjs/164523/2 "2009-04-02T08:47:45Z")

</div>

how about making it conditional? check existence of that div  
beforehand.

---

<div class="post-metadata">

**Author:** ![tkbeili](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7bcc69/32.png) [@tkbeili](https://www.ruby-forum.com/u/tkbeili)\
**Post date:** [April 2, 2009, 9:52am UTC](https://www.ruby-forum.com/t/how-to-eliminate-replace-html-alert-pop-up-in-rjs/164523/3 "2009-04-02T09:52:18Z")

</div>

Thanks MaD. Could you please provide a code on how to do this in RJS?

Thanks,

Tam

---

<div class="post-metadata">

**Author:** ![tkbeili](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7bcc69/32.png) [@tkbeili](https://www.ruby-forum.com/u/tkbeili)\
**Post date:** [April 2, 2009, 10:18am UTC](https://www.ruby-forum.com/t/how-to-eliminate-replace-html-alert-pop-up-in-rjs/164523/4 "2009-04-02T10:18:00Z")

</div>

there is a similar thread:  
[RJS - checking if element exists? - Rails - Ruby-Forum](http://www.ruby-forum.com/topic/87505)
