Here is the chat submit form:
#chat_form
- remote_form_for :chat, :url=>{:controller => "chats", :action=> "new", :id=>@request.id }, :html => { :autocomplete => 'off' } do |f|
= f.text_area "message_content", :rows=>5, :cols=>55, :autocomplete => "off"
= f.submit(value = "Sayit!", :class => "submit small")
chat#new.js.rjs
page << "$('#chat_message_content').val('')"
page.visual_effect :highlight, "chat_form"
Chats controller:
def new
@request = Request.find(params[:id])
@chat = Chat.new(params[:chat])
@chat.created_at = Time.now
@chat.user_id = current_user.id
@request.chats <<@chat
render :layout => false
end
"Sayit!" button is nice, but i need message sending by "Enter" button.
How it can be done ?
(i'm using jQuery)