How can I use 'user action' by configuring JavaScript?

When I input J from the keyboard on the computer, I can reveal the next cloze.
In the Ankimobile application, I want to use ‘user action’ to call JavaScript to reveal the next cloze.
I have tried many possibilities, but it prompts that the variable cannot be found or does not work.


This includes my template:
enhanced cloze

Can you teach me how to do it

It looks like the deck author hid it from the global scope. Try locating

     function revealOneClozeOfAType(clozeType) { ... },

and after the closing }, put the following:

globalThis["userJs1"] = revealOneClozeOfAType

Hello. I am very grateful to you.
Because I am a student, I cannot understand the code.
But I got inspiration from your code.
I have combined your code with the code provided by the template author.
Ultimately, the ‘user action1’ button can achieve functionality.
I added code after “}”: globalThis [“userJs1”] = () => revoalOneClozeOfAType (“genuine”).
Thank you very much. Without your help, I couldn’t have solved this difficulty

1 Like

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