A way to reload card front with JS?

Is there a way to trigger reloading the card webview with JS in the template? Specifically, I’m trying to figure out if it’s possible to make the custom scheduler get run again through a button in the template. This would allow setting additional custom data values into the card by injecting them through the globalThis object since the card front and custom scheduler share that. Then you could, for example, set Custom flags in AnkiDroid too.

2 Likes

I’m afraid I’m not sure exactly what you’re asking. The state mutation hook is an asynchronous function, and doesn’t need to resolve immediately.

Huh, I guess I didn’t understand how it worked. Then, I could do something like making the custom scheduler code wait until a promise is resolved where the resolving is done by javascript on the card front? The idea being that the custom scheduler code waits until

  1. the user presses some button on the card front which will resolve the promise
  2. or the user proceeds to the card back.

However, the hook does have to resolve on proceeding to the card back, right? Because the card back needs to have gotten the ease values for the answer buttons. For the custom flag use case, it’d be nice to be able modify the custom data from the card back as well, which would require having some way to re-run the state mutation hook which means returning to the card front programmatically.

Yep, that’s what I was thinking of. You may not be able to resolve the promise prior to the back side being revealed, but you could of course stuff hidden content into the front side if need be.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.