Skip to content

Commit b3e3723

Browse files
committed
Fix AJAX exercise JavaScript error
The error is now fixed and the Submit button is no longer disabled after submission. Fixes #1456
1 parent cfb4d82 commit b3e3723

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

exercise/static/exercise/chapter.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@
268268
$.ajax(exercise.url, {dataType: "html"})
269269
.done(function(data) {
270270
exercise.updateSummary($(data));
271+
exercise.dom_element.dispatchEvent(
272+
new CustomEvent("aplus:submission-finished",
273+
{bubbles: true, detail: {type: exercise.exercise_type}}));
271274
});
272275
}
273276
});
@@ -869,6 +872,7 @@
869872
},
870873

871874
fillFormInputs: function(submissionData, container) {
875+
if (!submissionData) return;
872876
submissionData.forEach(function([fieldName, fieldValue]) {
873877
const field = container.find('[name="' + fieldName + '"]');
874878
if (field.length === 0) return;

exercise/templates/exercise/exercise.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,11 @@
9696
$("#submit-progress").addClass("d-none");
9797
var $stats = $("#exercise-info"),
9898
url = $stats.data("url");
99-
$stats.load(url, function() {
100-
$stats.find('[data-bs-toggle="tooltip"]').tooltip();
101-
});
99+
if (url) {
100+
$stats.load(url, function() {
101+
$stats.find('[data-bs-toggle="tooltip"]').tooltip();
102+
});
103+
}
102104
}
103105
});
104106
</script>

0 commit comments

Comments
 (0)