Javascript code doesn't applied on all notes

Hello,

I created my custom card type with little javascript code inside.

Firstly I created without javascript then I edited javascript after studied some cards.

The javascript code is not applied on some notes when I review them.

I read in the Anki’s documentation (Javascript section) that the cards have some parts re-generated on review.
So I think my javascript code is not applied when I review already studied cards.

Anyone can help me about that ?
Can we force to regenerate all cards on review ?

Best regards.


Anki version :
Version ⁨2.1.66 (70506aeb)⁩
Python 3.9.15 Qt 6.5.2 PyQt 6.5.2

Platform : Windows 11

javascript code :

const pronunciationEl = document.getElementById('pronunciation');
const pronunContent = pronunciationEl.innerText.trim();
if (pronunContent.length == 0) {
	pronunciationEl.style.display = 'none';
}

Try wrapping the code in a function:

(() => {
	const pronunciationEl = document.getElementById('pronunciation');
	const pronunContent = pronunciationEl.innerText.trim();
	if (pronunContent.length == 0) {
		pronunciationEl.style.display = 'none';
	}
})();

See: Do javascript for loops work in html templates? - #5 by hkr

Firstly, thanks for your proposal. I will try and say you tomorrow if that works.

Secondly, I found a built-in feature in Anki that does what I want but anyway my topic continue to be interesting.

Thanks. I’ll reply tomorrow.

Hello.

That works very well.

Thanks for sharing me the tip.

Best regards.