views:

125

answers:

2

I'm using link_to_remote to update a div asynchronously, but it does not work. I have to refresh the page in order to see the change.

I use this to generate the links. http://ruby.pastebin.com/m1d83be81


"padding-left:30px", :display => "table-row" ) do %>
 
  • { :success => 'entry_' + entry.id.to_s}, :url =>{ :controller => :entries, :action => :increment ,:id => entry.id}, :with => "'amount=' +prompt('Amount')")%> { :success => 'entry_' + entry.id.to_s}, :url =>{ :controller => :entries, :action => :decrement ,:id => entry.id}, :with => "'amount=' +prompt('Amount')")%> { :success => 'entry_' + entry.id.to_s}, :url =>{ :controller => :entries, :action => :update ,:id => entry.id}, :with => "'amount=' +prompt('Amount')")%>
  • The corresponding actions all look like this:

    
      def increment
        @entry = Entry.find(params[:id])
        @entry.amount += params[:amount].to_i
        @entry.save!
        render :partial=>"entry", :object=>@entry
      end
    
    
    A: 

    I have found it helpful to specify the div to be updated in an :update in the controller action.

    salt.racer
    +1  A: 

    Remove the :success tag in your update clause and test:

    :update => 'entry_' + entry.id.to_s
    
    Ryan Oberoi