I have a delete button that when clicked triggers a popover. In that popover I have the real link doing the deleting. I want to select the id of the link inside that data-content
(Bootstrap) of of the popover.
I have multiple elements on a page that could be deleted so I don't know their IDs beforehand but they have the same class, so I generate an ID, then use $(this).attr('id')
to select the particular delete link.
This is the popover button and the link inside the data-content
<button tabindex="0" role="button" class="btn btn-danger btn-sm" data-toggle="popover"
data-placement="top" data-html="true" data-content="<a class='btn delete-draw text-danger'
id='[generatedId]'>Delete Draw</a>">Delete Draw
</button>
Now this is the jquery code
$(".delete-draw").click(function () {
event.preventDefault();
var drawId = $(this).attr("id");
// make ajax delete call
});
If I move the id
and .delete-draw
class to the outer popover button, it works well. So I'm thinking it has to do with the id
of the a
tag being nested in another data-attribute