Skip to content

Commit 8de181d

Browse files
author
David Heinemeier Hansson
authoredJun 15, 2021
Don't attach UJS form submission handlers to Turbo forms (rails#42476)
* Don't attach UJS form submission handlers to Turbo forms Allows for easier migration of apps written for UJS, such that new work can be done with Turbo forms that are marked with data-turbo=true. * Fix duplicate selectors * Proper fix take 2
1 parent 4e1fee1 commit 8de181d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎actionview/app/assets/javascripts/rails-ujs.coffee

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]'
1919

2020
# Form elements bound by rails-ujs
21-
formSubmitSelector: 'form'
21+
formSubmitSelector: 'form:not([data-turbo=true])',
2222

2323
# Form input elements bound by rails-ujs
24-
formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])'
24+
formInputClickSelector: 'form:not([data-turbo=true]) input[type=submit], form:not([data-turbo=true]) input[type=image], form:not([data-turbo=true]) button[type=submit], form:not([data-turbo=true]) button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])',
2525

2626
# Form input elements disabled during form submission
2727
formDisableSelector: 'input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled'

0 commit comments

Comments
 (0)
Please sign in to comment.