Hello,
I began a ruby application recently and I try to integrate Ajax touchs but I got a strange problem here.
In my view app/views/messages/index.rthml, I've got a simple link to a remote function and a container [code]<%= link_to_remote "Refresh", :url => { :controller => "messages", :action => "get_messages", :method => "get", :page => @messages.current_page }, :before => "Element.show('wait')", :complete => "Element.hide('wait')" %> <div id="messages_container"> <%= render :partial => "shared/messages/messages", :object => @messages %> </div> [/code]
In my controller app/controllers/messages_controller.rb, I've got the associated method : [code] def get_messages @messages = Message.paginate :page => params[:page], :per_page => Message.per_page, :limit => Message.per_page, :order => 'created_at DESC' end [/code]
and I finally have a RJS file name app/views/messages/get_messages.rjs with the following code: [code] page.replace_html ('messages_container', :partial => "shared/messages/messages", :object => @messages) [/code]
The problem is that the RJS file is *never* used/called by RoR and I do not understand why.
I'm sure the get_messages method in the controller is called and executed because when I put the JS instructions inthere, that's work : [code] def get_messages @messages = Message.paginate :page => params[:page], :per_page => Message.per_page, :limit => Message.per_page, :order => 'created_at DESC' render(:update) { |page| page.replace_html 'messages_container', :partial => 'shared/messages/messages', :object => @messages } end [/code]
I should be able to put the JS code in the RJS file, but it is ignored. When I tried to add an :update id in my link_to_remote call, the RJS is read but the container is replaced by the generated javascript code (not executed so).
Thx in advance if somebody has an idea !