I have a series of dropdown buttons on a page and am trying to trigger a single function with the button's id. Why is my function not getting called?
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle btn-sm btn-block" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Options
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="lists//details">Edit Details</a>
<a class="dropdown-item" href="#">Convert to...</a>
<a class="dropdown-item" href="#" id= "" class="copy-row">Copy</a>
</div>
</div>
and the JS:
$('.copy-row').click( function(e) {
e.preventDefault();
var token = $('meta[name="csrf-token"]').attr('content');
var id = $(this).attr('id');
$.ajax({url: '/lists/' + id, data: {_token:token}, type: 'PUT'})
window.location.reload();
});
via matt9292