<%= link_to "Delete", post_path(@post), data: confirm: "Delete this post?", method: :delete, remote: true %>
<%= form_for(@model, remote: true) do |form| %> <%= form.text_field :name %> <%= form.submit %> <% end %>
| Symptom | Likely Cause | |---------|---------------| | Remote link does a full page refresh | Missing remote: true or conflicting Turbo | | Delete link performs a GET | Missing method: :delete or rails-ujs not loaded | | Confirmation dialog shows twice | Duplicate event binding | | Disable_with not working | Element is a button inside <a> or mismatch with Turbo |
// Add custom data attribute data-loading-text document.addEventListener('ajax:before', function(e) let target = e.target; if (target.dataset.loadingText) target.innerText = target.dataset.loadingText;
Ultimately, rails-ujs is a shining example of Rails’ philosophy: Convention over Configuration and Unobtrusive JavaScript . It removes boilerplate, avoids vendor lock-in, and lets you focus on building features rather than wiring up events.
Add a simple confirmation before submitting a form or following a link.
If you are upgrading an app or working on a legacy project, you can check for UJS in a few places:
<%= link_to "Delete", post_path(@post), data: confirm: "Delete this post?", method: :delete, remote: true %>
<%= form_for(@model, remote: true) do |form| %> <%= form.text_field :name %> <%= form.submit %> <% end %> rails ujs
| Symptom | Likely Cause | |---------|---------------| | Remote link does a full page refresh | Missing remote: true or conflicting Turbo | | Delete link performs a GET | Missing method: :delete or rails-ujs not loaded | | Confirmation dialog shows twice | Duplicate event binding | | Disable_with not working | Element is a button inside <a> or mismatch with Turbo | If you are upgrading an app or working
// Add custom data attribute data-loading-text document.addEventListener('ajax:before', function(e) let target = e.target; if (target.dataset.loadingText) target.innerText = target.dataset.loadingText; %= link_to "Delete"
Ultimately, rails-ujs is a shining example of Rails’ philosophy: Convention over Configuration and Unobtrusive JavaScript . It removes boilerplate, avoids vendor lock-in, and lets you focus on building features rather than wiring up events.
Add a simple confirmation before submitting a form or following a link.
If you are upgrading an app or working on a legacy project, you can check for UJS in a few places:
Product Enquiry