Topic: IF statements in RJS files? I Need flow control!

I have a comments system working and ready. When the page is loaded and there aren't any comments, I have:

<% if @comments_submitted.empty? %>
<br>
<center><b><span id="nocomments">No one has commented yet. Be the first!</span></b></center>
<br>
<% else %>

The previous code creates an ID for my RJS file to remove when a comment is added:
page.replace_html 'nocomments', ""

Obviously, I need some sort of flow control! Because when there are comments, the "nocomments" span ID is not there. This throws an error, since there is no ID for myRJS file to replace!

Re: IF statements in RJS files? I Need flow control!

whats in the else portion of your html ?

Does it have a div for the entire comments section? if so I would move that outside the if comments block and then the "no comments" text will get overwritten presumably by your rjs

Re: IF statements in RJS files? I Need flow control!

Yeah, I just made an empty "noccmments" span ID for the else portion. It works now!