-
Notifications
You must be signed in to change notification settings - Fork 508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
button_tag doesn't trigger UJS driver unless it type='submit' #437
Comments
@rafaelfranca Thanks for migrating this, I probably should have thought about which repo to post this to, but I only had 5 minutes to think about it before class. |
@rafaelfranca I'm hitting this same issue this morning (trying to add From the maintainers' perspective, does it work to modify the |
From @cireficc on September 9, 2015 15:29
The
button_tag
will trigger the UJS driver only when the button'stype='submit'
.For example, if I want to generate a delete button with confirmation I could do:
button_tag "Delete", data: { confirm: "Are you sure you want to delete this resource?"}
However, I want to use a button with confirmation to delete a nested resource on the main resource's form, but if I use the above method, the button's type is
'submit'
so it immediately submits the form after confirmation. That is not desirable.I would like to use:
button_tag type: 'button', data: { confirm: "Are you sure you want to delete this resource?"}
However, because the button type is
'button'
and not'submit'
, the UJS driver isn't triggered, thus no confirmation is shown.It seems to me that the UJS driver should pick up anything that has
data-confirm
(anddata-disable
, for that matter), instead of only activating for'submit'
buttons.Is this by design or is this something that should be changed?
Copied from original issue: rails/rails#21564
The text was updated successfully, but these errors were encountered: