NodeJS-Epress how to redirect to rootpage from dynamic element?

HI, it’s there some trick to make click event to dynamic content? Or I want navbar-menu visible on all subsites.

In projecl like pinterestclone you call Db and populate root page with links if click them you are redirect to site with specific image or graph, but if I want menu visible I must call them from frontpage.js not routing to backend.

There is problem add get event with specific ID for retrieve data from db.

something like this

   for (let x = data.length-1 ; x != -1; x--) {
                
                $(".grid").append('<a id="+data[x]._id+" class="button view" href="view/'+ data[x]._id+'" >view</a>');

                     $('#'+data[x]._id).click(function (e) { 
                        e.preventDefault();
                 $.ajax({
                   url: '/view',
                   type: 'get',
                   dataType: 'json',
                   data: { id: data[x]._id },
                   success: function (data) {  
                
                    getMy(data);
                }
                });
                });
                
            }