Skip to content

Commit 4214a8d

Browse files
author
David Heinemeier Hansson
authored
Document that @rails/ujs is deprecated (rails#43112)
Recommended replacements: Turbo + Stimulus.
1 parent d5b9618 commit 4214a8d

File tree

2 files changed

+48
-39
lines changed

2 files changed

+48
-39
lines changed

actionview/lib/action_view/helpers/form_tag_helper.rb

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -453,16 +453,6 @@ def radio_button_tag(name, value, checked = false, options = {})
453453
# * <tt>:disabled</tt> - If true, the user will not be able to use this input.
454454
# * Any other key creates standard HTML options for the tag.
455455
#
456-
# ==== Data attributes
457-
#
458-
# * <tt>confirm: 'question?'</tt> - If present the unobtrusive JavaScript
459-
# drivers will provide a prompt with the question specified. If the user accepts,
460-
# the form is processed normally, otherwise no action is taken.
461-
# * <tt>:disable_with</tt> - Value of this parameter will be used as the value for a
462-
# disabled version of the submit button when the form is submitted. This feature is
463-
# provided by the unobtrusive JavaScript driver. To disable this feature for a single submit tag
464-
# pass <tt>:data => { disable_with: false }</tt> Defaults to value attribute.
465-
#
466456
# ==== Examples
467457
# submit_tag
468458
# # => <input name="commit" data-disable-with="Save changes" type="submit" value="Save changes" />
@@ -473,15 +463,28 @@ def radio_button_tag(name, value, checked = false, options = {})
473463
# submit_tag "Save edits", disabled: true
474464
# # => <input disabled="disabled" name="commit" data-disable-with="Save edits" type="submit" value="Save edits" />
475465
#
476-
# submit_tag "Complete sale", data: { disable_with: "Submitting..." }
477-
# # => <input name="commit" data-disable-with="Submitting..." type="submit" value="Complete sale" />
478-
#
479466
# submit_tag nil, class: "form_submit"
480467
# # => <input class="form_submit" name="commit" type="submit" />
481468
#
482469
# submit_tag "Edit", class: "edit_button"
483470
# # => <input class="edit_button" data-disable-with="Edit" name="commit" type="submit" value="Edit" />
484471
#
472+
# ==== Deprecated: Rails UJS attributes
473+
#
474+
# Prior to Rails 7, Rails shipped with the JavaScript library called @rails/ujs on by default. Following Rails 7,
475+
# this library is no longer on by default. This library integrated with the following options:
476+
#
477+
# * <tt>confirm: 'question?'</tt> - If present the unobtrusive JavaScript
478+
# drivers will provide a prompt with the question specified. If the user accepts,
479+
# the form is processed normally, otherwise no action is taken.
480+
# * <tt>:disable_with</tt> - Value of this parameter will be used as the value for a
481+
# disabled version of the submit button when the form is submitted. This feature is
482+
# provided by the unobtrusive JavaScript driver. To disable this feature for a single submit tag
483+
# pass <tt>:data => { disable_with: false }</tt> Defaults to value attribute.
484+
#
485+
# submit_tag "Complete sale", data: { disable_with: "Submitting..." }
486+
# # => <input name="commit" data-disable-with="Submitting..." type="submit" value="Complete sale" />
487+
#
485488
# submit_tag "Save", data: { confirm: "Are you sure?" }
486489
# # => <input name='commit' type='submit' value='Save' data-disable-with="Save" data-confirm="Are you sure?" />
487490
#
@@ -506,17 +509,6 @@ def submit_tag(value = "Save changes", options = {})
506509
# use this input.
507510
# * Any other key creates standard HTML options for the tag.
508511
#
509-
# ==== Data attributes
510-
#
511-
# * <tt>confirm: 'question?'</tt> - If present, the
512-
# unobtrusive JavaScript drivers will provide a prompt with
513-
# the question specified. If the user accepts, the form is
514-
# processed normally, otherwise no action is taken.
515-
# * <tt>:disable_with</tt> - Value of this parameter will be
516-
# used as the value for a disabled version of the submit
517-
# button when the form is submitted. This feature is provided
518-
# by the unobtrusive JavaScript driver.
519-
#
520512
# ==== Examples
521513
# button_tag
522514
# # => <button name="button" type="submit">Button</button>
@@ -537,6 +529,20 @@ def submit_tag(value = "Save changes", options = {})
537529
# # <strong>Ask me!</strong>
538530
# # </button>
539531
#
532+
# ==== Deprecated: Rails UJS attributes
533+
#
534+
# Prior to Rails 7, Rails shipped with a JavaScript library called @rails/ujs on by default. Following Rails 7,
535+
# this library is no longer on by default. This library integrated with the following options:
536+
#
537+
# * <tt>confirm: 'question?'</tt> - If present, the
538+
# unobtrusive JavaScript drivers will provide a prompt with
539+
# the question specified. If the user accepts, the form is
540+
# processed normally, otherwise no action is taken.
541+
# * <tt>:disable_with</tt> - Value of this parameter will be
542+
# used as the value for a disabled version of the submit
543+
# button when the form is submitted. This feature is provided
544+
# by the unobtrusive JavaScript driver.
545+
#
540546
# button_tag "Save", data: { confirm: "Are you sure?" }
541547
# # => <button name="button" type="submit" data-confirm="Are you sure?">Save</button>
542548
#

actionview/lib/action_view/helpers/url_helper.rb

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,8 @@ def _filtered_referrer # :nodoc:
103103
# completion of the Ajax request and performing JavaScript operations once
104104
# they're complete
105105
#
106-
# ==== Data attributes
107-
#
108-
# * <tt>confirm: 'question?'</tt> - This will allow the unobtrusive JavaScript
109-
# driver to prompt with the question specified (in this case, the
110-
# resulting text would be <tt>question?</tt>. If the user accepts, the
111-
# link is processed normally, otherwise no action is taken.
112-
# * <tt>:disable_with</tt> - Value of this parameter will be used as the
113-
# name for a disabled version of the link. This feature is provided by
114-
# the unobtrusive JavaScript driver.
115-
#
116106
# ==== Examples
107+
#
117108
# Because it relies on +url_for+, +link_to+ supports both older-style controller/action/id arguments
118109
# and newer RESTful routes. Current Rails style favors RESTful routes whenever possible, so base
119110
# your application on resources and use
@@ -186,15 +177,27 @@ def _filtered_referrer # :nodoc:
186177
# link_to("Destroy", "http://www.example.com", method: :delete)
187178
# # => <a href='http://www.example.com' rel="nofollow" data-method="delete">Destroy</a>
188179
#
189-
# You can also use custom data attributes using the <tt>:data</tt> option:
190-
#
191-
# link_to "Visit Other Site", "http://www.rubyonrails.org/", data: { confirm: "Are you sure?" }
192-
# # => <a href="http://www.rubyonrails.org/" data-confirm="Are you sure?">Visit Other Site</a>
193-
#
194180
# Also you can set any link attributes such as <tt>target</tt>, <tt>rel</tt>, <tt>type</tt>:
195181
#
196182
# link_to "External link", "http://www.rubyonrails.org/", target: "_blank", rel: "nofollow"
197183
# # => <a href="http://www.rubyonrails.org/" target="_blank" rel="nofollow">External link</a>
184+
#
185+
# ==== Deprecated: Rails UJS attributes
186+
#
187+
# Prior to Rails 7, Rails shipped with a JavaScript library called @rails/ujs on by default. Following Rails 7,
188+
# this library is no longer on by default. This library integrated with the following options:
189+
#
190+
# * <tt>confirm: 'question?'</tt> - This will allow the unobtrusive JavaScript
191+
# driver to prompt with the question specified (in this case, the
192+
# resulting text would be <tt>question?</tt>. If the user accepts, the
193+
# link is processed normally, otherwise no action is taken.
194+
# * <tt>:disable_with</tt> - Value of this parameter will be used as the
195+
# name for a disabled version of the link. This feature is provided by
196+
# the unobtrusive JavaScript driver.
197+
#
198+
# link_to "Visit Other Site", "http://www.rubyonrails.org/", data: { confirm: "Are you sure?" }
199+
# # => <a href="http://www.rubyonrails.org/" data-confirm="Are you sure?">Visit Other Site</a>
200+
#
198201
def link_to(name = nil, options = nil, html_options = nil, &block)
199202
html_options, options, name = options, name, block if block_given?
200203
options ||= {}

0 commit comments

Comments
 (0)