Skip to content

Embedded ajax-exercises throw JS error #1456

@murhum1

Description

@murhum1

Submitting ajax-exercises throws a JS error when embedded into course material. When grading results come back, an a-plus-refresh-stats event is emitted, the handler for the event tries to update an #exercise-info element, which only exists on standalone exercise pages.

FIX: Add a check to see if the element is present before trying to run the .load function.

Image

window.addEventListener("message", function (event) {
if (event.data.type === "a-plus-refresh-stats") {
$("#submit-progress").addClass("hide");
var $stats = $("#exercise-info"),
url = $stats.data("url");
$stats.load(url, function() {
$stats.find('[data-toggle="tooltip"]').tooltip();
});
}
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions