Skip to content

Commit 6e5d210

Browse files
committed
Switch ww_applet_support.js from using a submit handler to click handlers on the submit buttons.
This makes applet problems work in the PG problem editor of webwork2. The PG problem editor uses click handlers on the submit buttons as well, but calls `preventDefault` on the event, and prevents the form submission from occuring. That prevents the current submit handler set in the ww_applet_support.js code from happening. Thus the answers for applets do not get submitted. By using the click handlers this gets in at the same point that the PG problem editor handlers are, and they still occur. All click handlers are executed even if one of them prevents default behavior.
1 parent 85cfe93 commit 6e5d210

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

htdocs/js/AppletSupport/ww_applet_support.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,14 @@ class ww_applet {
274274
if (form.submitHandlerInitialized) return;
275275
form.submitHandlerInitialized = true;
276276

277-
// Connect the submit action handler to the form.
278-
form.addEventListener('submit', () => {
279-
for (const appletName in ww_applet_list) {
280-
ww_applet_list[appletName].submitAction();
281-
}
282-
});
277+
// Connect the submit action handler to the form submit buttons.
278+
for (const button of form.querySelectorAll('input[type="submit"]')) {
279+
button.addEventListener('click', () => {
280+
for (const appletName in ww_applet_list) {
281+
ww_applet_list[appletName].submitAction();
282+
}
283+
});
284+
}
283285
};
284286

285287
// Initialize applet support and the applets.

0 commit comments

Comments
 (0)