开发者

Rails :confirm does not show dialog box

I have a rails app with the following code in one of my views:

<% 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 %&g开发者_运维问答t;
<% end %>

However, I don't get a javascript dialog box showing - it just seems to skip that bit (the calling of the action works).

My application layout has the following:

  <%= stylesheet_link_tag :all %>
  <%= javascript_include_tag :defaults %>
  <%= csrf_meta_tag %>

So I think I have the necessary javascript loaded.

Any ideas why this isn't working?


As the documentation shows

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

in

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

try using like this

<% 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 %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜