How can I manually re-enable links (not form elements) that get disabled with Rails' disable_with
feature?
The call to reenable links is slightly different than form elements. It actually binds a handler to the click event that stops anything else from happening. I was able to figure this out by investigating how the jquery-ujs library.
To reverse this effect, simply use the enableElement
method on your jQuery object:
$.rails.enableElement($('a[data-disable-with]'));
With Turbolinks, it also helps to watch for the 'page:change'
event instead of window.unload
:
$(document).on('page:change', function() {
$.rails.enableElement($('a[data-disable-with]'));
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With