So I wanted to delete a row in a table using a delete button, which will then show a modal to confirm the delete process. However, I need to pass the ID, in this case I used filename, to the URL in order to complete the delete process. However, I can't seem to pass the complete URL in order to delete in the "YES" button in the modal. I am trying to simulate a process like this: Plunker
Here's the code.
Modal:
<div class="modal-body text-center">
<p> Are you sure you want to remove this from the list? </p><br><br>
<button type="submit" class="btn btn-custom-1">Yes</button>
<button type="button" class="btn btn-custom" data-dismiss="modal">Cancel</button>
</div>
Delete Button:
<button type="button" class="btn btn-custom-3" data-href="<?php echo base_url() . 'admin_forms/delete_carsticker/' . $row->filename; ?>" data-toggle="modal" data-target="#delete-modal"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete </button>
Javascript:
$('#delete-modal').on('show.bs.modal', function(e) {
$(this).find('.btn-custom-1').attr('href', $(e.relatedTarget).data('href'));
});