Rails、元素显示和页面更新

发布于 2024-09-07 20:00:15 字数 572 浏览 2 评论 0原文

我有一系列 div,每个 div 都有一个删除链接。每一个还有一个当前隐藏的旋转图像。想法是,当按下删除链接时(并且 div 中的对象被删除),将显示微调器。一旦完成删除对象的 AJAX 调用,div 项目就会从系列中删除。

我的问题基本上是显示旋转图像。

这是我正在使用的代码:

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

remote_function 部分调用一个 rjs,它会正确删除相关的 div,所以这不是问题。但是,显示微调器的 update_page 部分不起作用,我真的不明白为什么。

有什么想法吗?谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赴月观长安 2024-09-14 20:00:15

我更改了代码以使用 :before 选项,该选项是 remote_function 调用的一部分,并且它有效。

  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

耶!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文