link_to:方法并确认:不工作

时间:2015-01-06 17:59:28

标签: javascript jquery ruby-on-rails ruby-on-rails-4 link-to

无论我尝试过多少解决方案,都没有任何效果。确认弹出窗口不会生成,每次只发送一次GET。

我尝试过这两种格式,都做同样的事情(没有)

%li= link_to 'Log out', destroy_user_session_path, method: "delete", data: {confirm: 'Are you sure?'}
%li= link_to 'Log out2', {controller: "users/sessions", action: "destroy"}, confirm: "Are you sure?"

以下是生成的HTML:

<a data-confirm="Are you sure?" rel="nofollow" data-method="delete" href="/users/sign_out">Log out</a>

的application.js

//= require jquery
//= require jquery_ujs
//= require foundation
//= require turbolinks
//= require_tree .

$(function(){ $(document).foundation(); });

application.html.haml

= stylesheet_link_tag    "application"
    = javascript_include_tag "vendor/modernizr"
    = javascript_include_tag "application" 'data-turbolinks-track' => true
    = csrf_meta_tags

1 个答案:

答案 0 :(得分:1)

这个怎么样:

<%= link_to 'Logout', destroy_user_session_path, method: :delete, data: {confirm: "sure"} %>

您不应该将删除标记放在引号中。