I can't binding event in a tag during implementing pjax

25 Views Asked by At

I was implementing pjax. However, the href attribute on the link tag still works. preventDefault() with addEventListener; I also tried to apply return false; as well. How can I prevent the href tag from working?

My code: (link is a predefined function that sends pjax as an argument value. It is simply sent, so it doesn't matter here.)

document.querySelectorAll('a').forEach(addEventListener('click', function(){
    preventDefault();
    link(location.pathname);
};);
0

There are 0 best solutions below