I use SignalR to push notifications. To be simple, I have created some elements using the following jQuery code:
<script>
    $(document).ready(function(){
        var connection = new signalR.HubConnectionBuilder().withUrl("/signalRServer").withAutomaticReconnect().build();
        connection.start();
        connection.on("ReceiveNotification", function(sender, workCenter, serviceType, notificationId){
            event.preventDefault();
            if($('#notifi-badge').length){
                var currentNotificationCount = parseInt($('#notifi-badge').text());
                $('#notifi-badge').text(currentNotificationCount + 1);
                $('.notification-items').prepend('<li><a class="dropdown-item notification-item" style="font-family: vazir !important" Id="'+ notificationId +'" href="#">New '+ serviceType +' for '+ workCenter +' sent.</a></li>');
            }else{
                $('#notifi-badge').text('1');
            }
        });
    });
</script> 
and I use the following code to detect those created items:
<script>
    $(document).ready(function(){
        $('.notification-item').on("click", function(){
        var selectedId = $(this).attr('Id');
        var notificationBadge = parseInt($('#notifi-badge').text());
        var formData = new FormData();
        alert(selectedId);
. . .
</script>
SignalR works fine and I can push notifications. When I click those created elements, I expect to alert but it does not.
 
    