From c15e5739eb986266caa86ff66431fbf7c7e878f1 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Fri, 22 Sep 2023 13:22:55 +0200 Subject: [PATCH] Only run query selector once --- app/views/evaluations/show.js.erb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/evaluations/show.js.erb b/app/views/evaluations/show.js.erb index c298baaa15..0130fdaf5d 100644 --- a/app/views/evaluations/show.js.erb +++ b/app/views/evaluations/show.js.erb @@ -1,4 +1,8 @@ dodona.setHTMLExecuteScripts(document.querySelector("#evaluation-table-wrapper"), "<%= escape_javascript(render 'evaluation_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users) %>") -if(document.querySelector("#evaluation-grade-table-wrapper")) { - dodona.setHTMLExecuteScripts(document.querySelector("#evaluation-grade-table-wrapper"), "<%= escape_javascript(render 'evaluation_grade_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users) %>") +{ + const gradeTable = document.querySelector("#evaluation-grade-table-wrapper"); + if(gradeTable) { + dodona.setHTMLExecuteScripts(gradeTable, "<%= escape_javascript(render 'evaluation_grade_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users) %>") + } } +