我真的很想弄清楚这个问题。我试图在销毁记录后在索引页面上触发确认模式。一旦我在删除页面上销毁了一条记录,我想重定向到索引页面并自动创建一个“恭喜,您已删除一条记录”。我不想使用警报...我想使用模式。
提前致谢!
这是我尝试过的一些方法(我的 Modal 的 id 为 #destroyedSuccess)
<%= link_to "Delete Project", records_path, :class => "btn", :remote => true, "data-toggle" => "modal", "data-target" => "#destroyedSuccess"%>
<%= link_to "Delete Project", records_path, "data-toggle" => "modal", 'data-target' => '#destroyedSuccess' %>
最佳答案
尝试通过js触发app/views/records/destroy.js.erb
文件中的模态。
$("#destroyedSuccess").modal()
您也可以将哈希中的其他选项传递给模态。
如果你重定向到索引操作,那么你需要通过js触发它相应的文件。
关于javascript - 使用参数而不是 Rails 中的按钮触发 Bootstrap 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27744329/