0
我正在使用disable_with
,並且無法使按鈕文本更改保留(因爲它正在被disable_with
功能覆蓋)。一旦我刪除, data: { disable_with: '...'
按鈕將按預期更新。如何在Rails的遠程窗體`disable_with`功能完成後執行Javascript?
在disable_with
功能完成後有沒有辦法執行操作?
形式:
<%= 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');
}
}