Saving dynamically added classes between passages

Hi all, second post in as many days and this one is more of a general question: is it possible to save dynamically added classes to an element between passage movements?

Right now I use jquery to add the link-visited class to only certain links, which works fine as long as I’m on the same passage, but as soon as I move to another the element resets to its original (sans link-visited) form (I also set Config.addVisitedLinkClass = true).

I’ve read on some older posts that such classes won’t persist like this, so is there any workaround? Thanks!

Edit: here is my jquery function in case it helps:

(function () {
  $(document).on("click", ".eoi", function (e) {
    $( e.target ).addClass( "link-visited" );
  });
}());

As explained in the Config.addVisitedLinkClass setting’s documentation that when enabled it uses the story’s History to determine if a specific link should be assigned the link-visited CSS class or not, and a simple test project like the following TWEE Notation can be used to demonstrate it working.

:: Story Javascript [script]
Config.addVisitedLinkClass = true;

:: Story Stylesheet [stylesheet]
.link-visited {
	color: yellow;
}

:: Start
[[First]]
[[Second]]
[[Third]]

:: First
First passage
[[Start]]
[[Second]]
[[Third]]

:: Second
Second passage
[[Start]]
[[First]]
[[Third]]

:: Third
Third passage
[[Start]]
[[First]]
[[Second]]

Your JavaScript example indicates that you only want to monitors for click events that is sent to HTML elements contained within the current page (eg. document) that have been assigned an eoi CSS class. You would possible need to use HTML Attribute based links if you wanted to directly assign the eoi class to a link.

<a data-passage="PassageName" class="eoi">Do the thing</a>

I am unsure why you are enabling the Config.addVisitedLinkClass setting if you only want to target elements with the eoi class.

is it possible to save dynamically added classes to an element between passage movements

I’ve read on some older posts that such classes won’t persist like this

Each time a Passage Transition occurs the HTML elements contained within the area of the page that displays the ‘Current’ Passage are destroyed, this is why any CSS classes you added to previously existing HTML element are lost and why you would need to re-apply such classes the next time the target element exists.