gpt4 book ai didi

ruby-on-rails - rails :confirm does not show dialog box

转载 作者:行者123 更新时间:2023-12-04 07:39:12 25 4
gpt4 key购买 nike

我的一个 View 中有一个带有以下代码的 rails 应用程序:

<% if @present.taken == false %>
<%= link_to "I want to buy this present", :confirm => 'Are you sure you want to buy this present?', :action => "taken_toggle", :id => @present.id %>
<% end %>

但是,我没有看到 javascript 对话框显示 - 它似乎只是跳过了那一点(操作的调用有效)。

我的应用程序布局如下:
  <%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>

所以我想我已经加载了必要的javascript。

任何想法为什么这不起作用?

最佳答案

正如文档所示

http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to



Be careful when using the older argument style, as an extra literal hash is needed:



尝试像这样使用
<% if @present.taken == false %>
<%= link_to "I want to buy this present", { :action => "taken_toggle"}, :confirm => 'Are you sure you want to buy this present?', :id => @present.id %>
<% end %>

关于ruby-on-rails - rails :confirm does not show dialog box,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5927305/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com