views:

17

answers:

1

I have a series of divs, and each one has a delete link. Each one also has a currently hidden spinner image. Idea is that when the delete link is pressed (and the object in the div is being deleted), the spinner is displayed. Once the AJAX call to delete the object is done, then the div item is removed from the series.

My problem here is basically getting the spinner image to display.

This is the code I am using:

  def destroy_object(object)
    update_page do |page|
      page.show "spinner-del-#{object.id}"
    end
    remote_function(
      :url => url_for(object),
      :method => :delete
    )
  end

The remote_function portion calls an rjs which removes the relevant div properly, so that's not an issue. However, the update_page section to show the spinner isn't working, and I really can't figure out why.

Any ideas? Thanks!

A: 

I changed the code to use the :before option that is part of the remote_function call, and it worked.

  def destroy_object(object)
    remote_function(
      :url => url_for(object),
      :method => :delete,
      :confirm => "Are you sure you wish to delete?",
      :before => "Element.show('spinner-del-#{object.id}')"
    )
  end

Yay!

Jty.tan