我有多个具有相同类名和不同 id 的按钮。但是当我点击按钮时,每次都会调用不止一个。有关正在运行的代码的信息,请观看视频:https : //nimb.ws/3RMoNP这是我的代码$(document).on("click", ".delete_attachment_confirmation", function(e){ e.preventDefault(); var attachment_id = $(this).data('attachmentid'); $('#delete_attachment_confirmation_'+attachment_id).attr("disabled", true); $('#delete_attachment_confirmation_'+attachment_id).text("Deleting file"); $.ajax({ url: "<?php echo base_url('attachment/delete_attachment/')?>"+$(this).data('attachmentid'), type: "GET", dataType: "text", success: function(data){ $("#row_"+attachment_id).remove(); $("#attachment_message_body").text(data); $('#delete_attachment_'+attachment_id).modal('hide'); // attachment message $('#attachment_message').modal('show'); // modal issue removal trick $('.modal-backdrop').removeClass('modal-backdrop'); } }); });<button class="btn btn-danger delete_attachment_confirmation" id="delete_attachment_confirmation_<?=$row->id?>" data-attachmentid="<?=$row->id?>" ><?php echo $this->lang->line('btn_modal_delete');?>更新按钮代码<button class="btn btn-danger delete_attachment_confirmation" id="delete_attachment_confirmation_<?=$row->id?>" data-attachmentid="<?=$row->id?>" ><?php echo $this->lang->line('btn_modal_delete');?>突出显示的部分向我们展示了 ajax 函数被多次调用。
添加回答
举报
0/150
提交
取消