简体   繁体   中英

link_to :method and confirm: not working

No matter how many solutions I've tried, nothing is working. Confirm popup will not generate, and it will ONLY send a GET every time.

I've tried both of these formats, both do the same thing (nothing)

%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?"

Here is the HTML generated:

<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

How about this :

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

You should not put the delete in quotes .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM