I have a bunch of buttons, 3 in total.
These buttons are messing with my head ha, The buttons are disabling in a weird order. If i press button 2, it'll disable (it disables because its submitting data to the database) Once it disables i can click button 3 to submit the data but it won't disable. However. Button one will.
Its kinda the same for other methods. If you press button 3 it'll disable and i can disable the other two. If i click button one, I can't disable the other two but it data submits fine.
When explaining this would you be gentle? I've only just started with rails haha!
Heres the code;
<div id="a" style="margin-right: 5px; float: left;">
<% if @conference_status.cross_charged_user_id.present? %>
<button id="a" class="btn btn-primary" disabled="disabled">Disabled</button>
<% else %>
<%= link_to 'Cross charged to Client', admin_conference_status_path(@conference_status, status_name: 'cross_charged_use'), class: "btn btn-primary", method: :put, remote: true, prompt: 'Are you sure?' %>
<% end %>
</div>
<div id="b" style="margin-right: 5px; float: left;">
<% if @conference_status.payment_received_comm_user_id.present? %>
<button class="btn btn-primary" disabled="disabled">Disabled</button>
<% else %>
<%= link_to 'Payment received Commission', admin_conference_status_path(@conference_status, status_name: 'payment_received_comm'), class: "btn btn-primary", method: :put, remote: true %>
<% end %>
</div>
<div id="c" style="margin-right: 5px; float: left;">
<% if @conference_status.payment_received_client_user_id.present? %>
<button class="btn btn-primary" disabled="disabled">Disabled</button>
<% else %>
<%= link_to 'Payment Received', admin_conference_status_path(@conference_status, status_name: 'payment_received'), class: "btn btn-primary", method: :put, remote: true %>
<% end %>
</div>
And heres the js.erb
<% if @conference_status.cross_charged_datetime.present? %>
$('#a').html('<button class="btn btn-primary" disabled="disabled">Disabled</button>');
<% elsif @conference_status.payment_received_comm_user_id.present? %>
$('#b').html('<button class="btn btn-primary" disabled="disabled">Disabled</button>');
<% else @conference_status.payment_received_client_datetime.present? %>
$('#c').html('<button class="btn btn-primary" disabled="disabled">Disabled</button>');
<% end %>
Okay,
I fixed this using the If Command repeatedly. The elsif and else seemed to be messing it up. So just changing them all to If in the Js.erb and adding <% end %>
works fine
Sam
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.