RJS not executed

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’)” %>

<%= render :partial => "shared/messages/messages", :object => @messages %>
[/code]

In my controller app/controllers/messages_controller.rb, I’ve got the
associated method :

  def get_messages
  @messages = Message.paginate :page => params[:page], :per_page =>
Message.per_page,
     :limit => Message.per_page,
     :order => 'created_at DESC'
  end

and I finally have a RJS file name app/views/messages/get_messages.rjs
with the following code:

page.replace_html ('messages_container', :partial =>
"shared/messages/messages", :object => @messages)

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 :

  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

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 !

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs