allert does not work
hww opened this issue · 1 comments
hww commented
Ruby 3.2.0
Rails 7.0.4.2
With fresh rails application then following instruction to install jquery-rails in the README.md
The URL generated by expression below -- does not show confirm form
<%= link_to 'Destroy', "/foo", method: :delete, data: { confirm: 'Are you sure?' } %>
The application.html.erb contains
<!DOCTYPE html>
<html>
<head>
<title>Xxx</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
</head>
The application.js
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import "@hotwired/turbo-rails"
import "controllers"
//= require jquery
//= require jquery_ujs
//= require_tree .
The page header is
<!DOCTYPE html>
<html>
<head>
<title>Xxx</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="e0esRsHAl_Z4J322Ze8sIOYla0GllZjFzk-bQJriKL5xfaOROoDjw5IB23LiYWi-UHsx5doIl1z1DZJm5dBpzQ" />
<link rel="stylesheet" href="[/assets/application-e0cf9d8fcb18bf7f909d8d91a5e78499f82ac29523d475bf3a9ab265d5e2b451.css](view-source:http://localhost:3000/assets/application-e0cf9d8fcb18bf7f909d8d91a5e78499f82ac29523d475bf3a9ab265d5e2b451.css)" data-turbo-track="reload" />
<script type="importmap" data-turbo-track="reload">{
"imports": {
"application": "/assets/application-87645a267be028a66c203a08e4154b30f544ba858336cb372b1d0e9278746b85.js",
"@hotwired/turbo-rails": "/assets/turbo.min-eef6d0d72563b8765529b3f72bffff1fb8dcdd7f6a0eb025a2478c06e030d1cf.js",
"@hotwired/stimulus": "/assets/stimulus.min-d03cf1dff41d6c5698ec2c5d6a501615a7a33754dbeef8d1edd31c928d17c652.js",
"@hotwired/stimulus-loading": "/assets/stimulus-loading-1fc59770fb1654500044afd3f5f6d7d00800e5be36746d55b94a2963a7a228aa.js",
"controllers/application": "/assets/controllers/application-368d98631bccbf2349e0d4f8269afb3fe9625118341966de054759d96ea86c7e.js",
"controllers/hello_controller": "/assets/controllers/hello_controller-549135e8e7c683a538c3d6d517339ba470fcfb79d62f738a0a089ba41851a554.js",
"controllers": "/assets/controllers/index-2db729dddcc5b979110e98de4b6720f83f91a123172e87281d5a58410fc43806.js"
}
}</script>
<link rel="modulepreload" href="[/assets/application-87645a267be028a66c203a08e4154b30f544ba858336cb372b1d0e9278746b85.js](view-source:http://localhost:3000/assets/application-87645a267be028a66c203a08e4154b30f544ba858336cb372b1d0e9278746b85.js)">
<link rel="modulepreload" href="[/assets/turbo.min-eef6d0d72563b8765529b3f72bffff1fb8dcdd7f6a0eb025a2478c06e030d1cf.js](view-source:http://localhost:3000/assets/turbo.min-eef6d0d72563b8765529b3f72bffff1fb8dcdd7f6a0eb025a2478c06e030d1cf.js)">
<link rel="modulepreload" href="[/assets/stimulus.min-d03cf1dff41d6c5698ec2c5d6a501615a7a33754dbeef8d1edd31c928d17c652.js](view-source:http://localhost:3000/assets/stimulus.min-d03cf1dff41d6c5698ec2c5d6a501615a7a33754dbeef8d1edd31c928d17c652.js)">
<link rel="modulepreload" href="[/assets/stimulus-loading-1fc59770fb1654500044afd3f5f6d7d00800e5be36746d55b94a2963a7a228aa.js](view-source:http://localhost:3000/assets/stimulus-loading-1fc59770fb1654500044afd3f5f6d7d00800e5be36746d55b94a2963a7a228aa.js)">
<script src="[/assets/es-module-shims.min-d89e73202ec09dede55fb74115af9c5f9f2bb965433de1c2446e1faa6dac2470.js](view-source:http://localhost:3000/assets/es-module-shims.min-d89e73202ec09dede55fb74115af9c5f9f2bb965433de1c2446e1faa6dac2470.js)" async="async" data-turbo-track="reload"></script>
<script type="module">import "application"</script>
</head>
<body>
<a data-confirm="Are you sure?" rel="nofollow" data-method="delete" href="[/ffff](view-source:http://localhost:3000/foo)">Destroy</a>
</body>
</html>
hww commented
Found those links are working
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?", turbo_method: :delete }, method: :delete %></p><br>
<p>Try this <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?" }, method: :delete %></p>