zjosua / anki-mc

Multiple choice questions for Anki.
https://ankiweb.net/shared/info/1566095810
GNU Affero General Public License v3.0
49 stars 16 forks source link

Invalid HTML on card: TypeError: Cannot read property 'innerHTML' of undefined #25

Closed avanhulle closed 2 years ago

avanhulle commented 3 years ago

When I use this card I get the following error message:

Invalid HTML on card: TypeError: Cannot read property 'innerHTML' of undefined TypeError: Cannot read property 'innerHTML' of undefined at onShuffle (eval at (http://127.0.0.1:6827/_anki/jquery.js:2:2651), :71:111) at generateTable (eval at (http://127.0.0.1:6827/_anki/jquery.js:2:2651), :32:9) at eval (eval at (http://127.0.0.1:6827/_anki/jquery.js:2:2651), :130:20) at eval () at http://127.0.0.1:6827/_anki/jquery.js:2:2651 at Function.globalEval (http://127.0.0.1:6827/_anki/jquery.js:2:2662) at Ha (http://127.0.0.1:6827/_anki/jquery.js:3:21262) at n.fn.init.append (http://127.0.0.1:6827/_anki/jquery.js:3:22791) at n.fn.init. (http://127.0.0.1:6827/_anki/jquery.js:3:24070) at Y (http://127.0.0.1:6827/_anki/jquery.js:3:4515)

Using this on Windows 10 PC. On android device the card is showing but I get "Correct answer x%"

rdvrd commented 3 years ago

I have the same issue as what you get on android but on both ankidroid as well as windows. I'm not sure why that elment is not being replaced

zjosua commented 3 years ago

@avanhulle and @rdvrd is this still a problem with the newest version of the add-on?

rdvrd commented 3 years ago

I now have this error on the back card with the new version:

Invalid HTML on card: TypeError: Persistence.getItem is not a function
TypeError: Persistence.getItem is not a function
at onLoad (eval at (http://127.0.0.1:51055/_anki/jquery.js:2:2651), :9:52)
at run (eval at (http://127.0.0.1:51055/_anki/jquery.js:2:2651), :95:20)
at eval (eval at (http://127.0.0.1:51055/_anki/jquery.js:2:2651), :115:9)
at eval ()
at http://127.0.0.1:51055/_anki/jquery.js:2:2651
at Function.globalEval (http://127.0.0.1:51055/_anki/jquery.js:2:2662)
at Ha (http://127.0.0.1:51055/_anki/jquery.js:3:21262)
at n.fn.init.append (http://127.0.0.1:51055/_anki/jquery.js:3:22791)
at n.fn.init. (http://127.0.0.1:51055/_anki/jquery.js:3:24070)
at Y (http://127.0.0.1:51055/_anki/jquery.js:3:4515)
3ter commented 3 years ago

I've got that error too, but only in the console when debugging and only when viewing the back card with "Manage Note Types...".

With the stacktrace and everything it seems that this is instead a full blown exception for you when reviewing cards. Is this the latest version of anki as well?

When checked in a regular browser (e.g. Chrome) persistence is properly recognized as a function: image

3ter commented 3 years ago

Thanks to @zjosua all dependencies are now included in the release and the update worked fine for me.

Can you @rdvrd or @avanhulle please check if the errors keep quiet now (on anki 2.1.42 / addon 2.4.1)?

Estreia18 commented 3 years ago

I still get following error message on the back card (sry - its only in the preview!):

Invalid HTML on card: TypeError: Persistence.getItem is not a function TypeError: Persistence.getItem is not a function at onLoad (eval at (http://127.0.0.1:56701/_anki/js/vendor/jquery.js:2:2651), :9:52) at run (eval at (http://127.0.0.1:56701/_anki/js/vendor/jquery.js:2:2651), :95:20) at eval (eval at (http://127.0.0.1:56701/_anki/js/vendor/jquery.js:2:2651), :115:9) at eval () at http://127.0.0.1:56701/_anki/js/vendor/jquery.js:2:2651 at Function.globalEval (http://127.0.0.1:56701/_anki/js/vendor/jquery.js:2:2662) at Ha (http://127.0.0.1:56701/_anki/js/vendor/jquery.js:3:21262) at n.fn.init.append (http://127.0.0.1:56701/_anki/js/vendor/jquery.js:3:22791) at n.fn.init. (http://127.0.0.1:56701/_anki/js/vendor/jquery.js:3:24070) at Y (http://127.0.0.1:56701/_anki/js/vendor/jquery.js:3:4515)

3ter commented 3 years ago

I don't really understand why this is triggered on some systems and not another. The error triggering line is this, where the html string is put into an html function I couldn't find in the anki repo.

// update text
try {
    qa.html(html);
} catch (error) {
    renderError("HTML")(error);
}
3ter commented 2 years ago

Previewing now works as expected.