Reputation: 37
hy, i want to pass my id to a tag href in my modal(bootstrap), for know i using this to past my id from my modal button :
modal.find('#down').attr('href', function(i, href) {
return href + div.data('id');
});
this is my a tag:
<a type="button" id="down" href="<?php echo base_url(); ?>/aprove/download/">Berkas</a>
this is my modal button:
<a href="javascript:;" title="Lihat" data-id="<?php echo $q->id_project ?>" data-toggle="modal" data-target="#lihat-data"> <button data-toggle="modal" data-target="#ubah-data" class="btn btn-secondary"><i class="far fa-eye"></i></i></button> </a>
the problem its, every time i click the modal button, my a tag(href) will add previous id to the new one, like this:
first modal:
href="http://localhost/pe//aprove/download/4"
second modal:
href="http://localhost/pe//aprove/download/41"
i need to refresh the table to make it just get their own id
Upvotes: 0
Views: 801
Reputation: 207511
So do something like
<a type="button" id="down" data-href="<?php echo base_url(); ?>/aprove/download/">Berkas</a>
and read the data attribute
var anchor = modal.find('#down')
anchor.attr('href', anchor.data('href') + div.data('id'));
Upvotes: 1