'How to make data:{confirm..} work in rails 6 | button_to
my confirm popup not working in rails 6. I added gem 'jquery-rails' to GEMFILE and run bundle install. I also added
//= require jquery
//= require jquery_ujs
this in application.js which is linked in layouts/application.html.erb as
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
Button working, and delete users, but there is not popup, where i can confirm, that i want to delete that user. What am i doing wrong?
This is my code in dashboard.html.erb
<%= button_to "Delete account",
admin_dashboard2_path(currentUser.id),
method: :delete,
data: {confirm:'Are you sure?'},
class: 'btn btn-primary'
%>
This is code in browser:
<form class="button_to" method="post" action="/ed-admin/39"><input type="hidden" name="_method" value="delete" /><input data-confirm="Are you sure?" class="btn btn-primary" type="submit" value="Delete account" /><input type="hidden" name="authenticity_token" value="WFyXCkE6r4vmcecfQF_ngWlHHU22bkKRLTT_cNeAC47szzjOd9JtuY_33L_4BUdWIcudhKRN0seWNO5QZ6MCfQ" /></form>```
Solution 1:[1]
You can use data-confirm-modal gem to do this,hope it will work https://github.com/ifad/data-confirm-modal
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Imran Khan |