Closed wezzou1 closed 6 years ago
Hi @wezzou1 !
The workaround would be to select all links in the admin bar after calling Highway.Core and store them in a variable so you can loop on them and remover the click
listener. Here is an example of the code you can try:
// Select all links
const adminBarLinks = document.querySelectorAll('.classOfAdminBar a');
// Call Highway.Core
const H = new Highway.Core([...]);
// Remove Listener at Runtime
for (let link of adminBarLinks) {
link.removeEventListener('click', H._navigate);
}
// Do it again on NAVIGATE_END
H.on('NAVIGATE_END', () => {
// Remove Listener at Runtime
for (let link of adminBarLinks) {
link.removeEventListener('click', H._navigate);
}
});
I didn't had time to try this code so feel free to come back to us if it don't do the trick.
We'll see to implement a better solution for the next release like a method in Highway.Core
where you'll be able to send a DOM Element to remove the listener or to add it when you want.
Best regards, Anthodpnt
Thank you @Anthodpnt, works like a charm!
It's that possible to update "links" in wp-admin-bar on each page'transition? I know it's outside the main-router, but it would be nice to update some the links
Best regards, Jesper
I'm not sure to understand @wezzou1.
You could do that in the NAVIGATE_END
event I guess...
@Anthodpnt Thanks! Will try.. 👍
Hi, first of all, very nice javascript-libary, I have only tried barba before, But I already like Highway more. I have a question, I'm using wordpress and highway, and it's works fine. But, when adminbar is showing on site and when I click on it, it will run Highway transition, and I'm don't really know how to target the wp-admin-bar and add data-router-disabled to it, So my question is, how can I destroy it with only a custom class?
It will be good feature if you guys can add it to our repo, and include it in Highway! :)
If you are interested to see my progress, check the site Still in progress... but some content are there :)