While using the disable_with
feature, I am facing an issue where the button text does not persist due to the functionality of disable_with
overriding it. Upon removing the data: { disable_with: '...'
section, the buttons update correctly.
Is there a way to execute actions after the completion of the disable_with
functionality?
form:
<%= form_for @user, html: {id: 'follow-form'}, remote: true do |f| %>
<%= button_tag id: 'follow-btn', data: { disable_with: '...' } do %>
Follow
<% end %>
<% end %>
js:
$('#follow-form').on('ajax:success',function(data, status, xhr){
if (status.action == 'follow') {
$('#follow-btn').text('Unfollow');
} else {
$('#follow-btn').text('Follow');
}
}