Helpful Information
 
 
Category: Ruby Programming
Client Updating

I have a Shout/Chat box using Ajax Ruby on Rails.
The chat goes in just fine and uses Ajax with ease.

What I would like to have happen, instead of refreshing page every X seconds.
Is to make it post changes have been made to clients using the Shout Box.

Can any one help me get this going?

Below is the code in my rtml.



<div class="tableborder">
<div class="maintitle"><b>ShoutBox!</b></div>
Last 10 Shouts:
<hr size="1" align="left" width="100%" color="blue">
<div id="shouts" class="shoutpad" style="overflow:auto;">
<% @shoutLines = Shout.find(:all, :order => 'timestamp DESC', :limit => 10) %>
<% @shoutLines.each do |sl| %>
<% @user = User.find(sl.user_id) %>
<div class="hlight"><strong><%=h @user.username %></strong> on <%=h sl.timestamp %></div>
<%=h sl.text %>
<br /><br/>
<% end %>
</div>

<hr size="1" align="left" width="100%" color="blue">
<div class="tablepad">
<form action="../shout/create" method="post">
<b>Message: </b>
<input id="shout_message" name="shout[text]" size="20" type="text" value=""/>
<%= submit_tag 'Send' %>
</form>
</div>
</div>



I've been playing around with prototype.js with no luck.
I think that will make it work the way I need it.

Note: Eventually I need to figure out how to keep the scrolling there too, not just the last 10 shouts.

Thanks in advance










privacy (GDPR)