Checking $page->isOpen via Javascript

I’ve added page transitions to my project using Barba.js. I don’t understand Barba well enough to explain how it technically works, other than saying “push state ajax”.

I set it to only load and animate the main content section, and keeping the header static. This means the “active” class I normally add to my navigation item in PHP does not update between ajax reloads.

How can I emulate checking if $page->isOpen() via a javascript callback function?

Maybe add a data attribute with the page uri somewhere and compare the path of the url to the data attribute?

Well that was easy enough. I should really think some things through a bit better before posting :sweat_smile:

var path = window.location.pathname.split( '/' );
$('nav a[data-path=' + path[1] + ']').addClass('active');