Buttons disabling in a random order, Rails/javascript -
i have bunch of buttons, 3 in total.
these buttons messing head ha, buttons disabling in weird order. if press button 2, it'll disable (it disables because submitting data database) once disables can click button 3 submit data won't disable. however. button 1 will.
its kinda same other methods. if press button 3 it'll disable , can disable other two. if click button one, can't disable other 2 data submits fine.
when explaining gentle? i've started rails haha!
heres 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 client', admin_conference_status_path(@conference_status, status_name: 'cross_charged_use'), class: "btn btn-primary", method: :put, remote: true, prompt: 'are 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 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 using if command repeatedly. elsif , else seemed messing up. changing them if in js.erb , adding <% end %>
works fine
sam
Comments
Post a Comment