-
Notifications
You must be signed in to change notification settings - Fork 511
data-disable-with keeps the button disabled when the user hit browser's back button #357
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
Comments
I can't read that workaround. |
@sobrinho : Could you give more details to your workaround? It seems that I stumpled upon this same issue, although it occurs to me when reloading the page instead of hitting the back button. |
I posted the wrong link. The workaround I've seen is to set |
Wow, you are totally right, using something like |
I think it should be fixed by jquery-ujs, we just need to set autocomplete attribute automatically on data-disable-with inputs, something like that: <input type="submit" data-disable-with="Loading..."> Automatically goes to: <input type="submit" data-disable-with="Loading..." autocomplete="off"> If it is okay, I can make a pull request :) |
I'm not comfortable with pushing hacks like this with the JS code. Maybe there is somewhere in the Rails docs/guides that we add a note about this similar to what was done in Bootstrap? /cc @rafaelfranca |
Yeah, I'm not comfortable either but considering the This hack is harmless and since it will not cause any side-effect, I'm okay with it. |
Browsers... ¯_(ツ)_/¯ What is broken here are the browsers. The I don't want to add this hack to jquery-ujs too but I agree it is harmless and may save some time of people. It may be worth to add even if it is browsers fault. |
So, can I make a pull request? 😻 |
Yes. It will help to decide if it is worth or not. |
Firefox has a weird behavior where when you hit the back button it keeps the submit buttons and links on disabled state which even reloading the page do not re-enables them. Using the pageshow event, which is triggered every time a page loads, we can keep the rails-ujs behavior consistent with all other browsers. See https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching [Fixes rails#357]
See #385 |
Firefox has a weird behavior where when you hit the back button it keeps the submit buttons and links on disabled state which even reloading the page do not re-enables them. Using the pageshow event, which is triggered every time a page loads, we can keep the rails-ujs behavior consistent with all other browsers. See https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching [Fixes rails#357]
I just ran into this myself, this might be nice to ensure cross browser similar behavior... |
This is an old issue, but this is still occurring for me in, even in <%= link_to "<i class='fa fa-plus fa-inverse'></i>".html_safe, new_appointment_path,
class: "btn btn-success new pull-right", data: { disable_with: "<i class='fa fa-spinner fa-spin'></i>" },
id: "new_appointment_button", title: "New Appointment" %> On first click, it spins, but when you hit the back button in Chrome for example, it stays spinning. Maybe something to do with turbolinks? |
If the user hits the browser's back button after submitting a form, the submit button is kept disabled, we must refresh the page to the restore the button state.
I found this workaround which seems to be working: [I lost the link]
It happens on Safari and Firefox, Chrome is fine.
Not sure about other browsers, I do not have any other here :)
The text was updated successfully, but these errors were encountered: