# Making decision in RJS?

**URL:** <https://www.ruby-forum.com/t/making-decision-in-rjs/134395>\
**Category:** Rails\
**Created:** [April 10, 2008, 2:21pm UTC](https://www.ruby-forum.com/t/making-decision-in-rjs/134395 "2008-04-10T14:21:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [April 10, 2008, 2:21pm UTC](https://www.ruby-forum.com/t/making-decision-in-rjs/134395/1 "2008-04-10T14:21:24Z")

</div>

I have an .rjs file in which I want to check if ‘notice’ is there  
(whether hidden or visible) then it should remove it’s DOM. And if there  
is no ‘notice’, it shouldn’t do anything.

Please help.  
Thanks

---

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [April 10, 2008, 2:32pm UTC](https://www.ruby-forum.com/t/making-decision-in-rjs/134395/2 "2008-04-10T14:32:39Z")

</div>

On 10 Apr 2008, at 13:21, Vapor … wrote:

> I have an .rjs file in which I want to check if ‘notice’ is there  
> (whether hidden or visible) then it should remove it’s DOM. And if  
> there  
> is no ‘notice’, it shouldn’t do anything.

You can do things like

page \<\< “if($(‘notice’)) {”  
page[‘notice’].remove()  
page \<\< “}”

There’s a plugin that make this sort of thing easier  
([http://www.railslodge.com/plugins/491-js-if-blocks](http://www.railslodge.com/plugins/491-js-if-blocks)  
)

Fred

---

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [April 10, 2008, 2:38pm UTC](https://www.ruby-forum.com/t/making-decision-in-rjs/134395/3 "2008-04-10T14:38:15Z")

</div>

many thanks!
