Anki renders my card templates only once

I wrote some templates based on JS, but Anki render those only once. So, for example, my template appends to to word and changes the color of the page. It’s fine until you use Show Answer button, to disappears. And if continue to second car, there are no anymore to and custom color (the color stays from previous the first card).

Can reproduce it in Windows 11 (qt5 and qt6) and AnkiWeb, but not in AnkiDroid.

You’re probably getting this SyntaxError:
Identifier has already been declared Error in JavaScript | bobbyhadz.

Make sure to use var instead of let and const in the global scope (outside of functions) or wrap your scripts in IIFEs.


1 Like

Replace all let and const on var helped! Thanks!