In place ajax button

so you have a button that increments the number of packages, but the number of packages displayed does not update when the button is clicked to add another package?

give the element in which you write the number of packages an id, for example id=“<%= ‘wood’ + %>”.

then in your controller

def incrementing_function wood = Wood.find(params[:wood_id] wood.packages += 1 render(update) do |page| page.replace_html “wood” +, :partial => ‘partial you mentioned’, :locals => {:wood => wood} end end

if you use the partial you mentioned to render the original number of packages then you will replace the partial with the same partial, populated with the updated wood object.

hope that helps, if not, elaborate on your problem and maybe someone else will be able to help.


Costi Nicolaou wrote:

    <%= form_remote_tag(:url => { :action => 'vote', :id => },                                   :update => 'voting' + )

For a vote, why not use observe_form() and submit the vote at click time? Why make the user click twice just to vote once?

You don't work for Diebold, do you?


Costi Nicolaou wrote:

Can you pls elaborate on your idea? How the current one is posting twice?

Look observe_form() up.

Your current plan makes the user click their mouse on the check-box, then click on the Submit button.

If you instead observe the form, it will post each time the user changes it. In some usability contexts, such as voting, the post should be instant. Consider the Rating button on Google Groups posts. In other usability contexts, the users should make many changes and send them all at once. That's what Submit buttons are for.