fix: assign $$course_id in <head> to fix course-team-authored JS (#26745)
Course-team-authored JS expects $$course_id to be defined in the global scope. This has worked fine in Legacy courseware, but due to some differences in page loading (which I don't understand) between Legacy and Chromeless (ie New/MFE) XBlock rendering templates, $$course_id wasn't being assigned before course-team-authored JS was run, causing the scripts to break on the undefined variable. The fix here is to assign $$course_id in the <head>, guaranteeing that the variable is assigned before any other JS is run. TNL-7993
This commit is contained in:
@@ -51,6 +51,14 @@ ${static.get_page_title_breadcrumbs(course_name())}
|
||||
## in this iframe to navigate the parent window.
|
||||
<base target="_parent">
|
||||
%endif
|
||||
|
||||
## Expose the $$course_id variable for course-team-authored JS.
|
||||
## We assign it in the <head> so that it will definitely be
|
||||
## assigned before any in-XBlock JS is run.
|
||||
<script type="text/javascript">
|
||||
var $$course_id = "${course.id | n, js_escaped_string}";
|
||||
</script>
|
||||
|
||||
</%block>
|
||||
|
||||
<%block name="js_extra">
|
||||
@@ -66,10 +74,6 @@ ${static.get_page_title_breadcrumbs(course_name())}
|
||||
<%include file="xqa_interface.html"/>
|
||||
% endif
|
||||
|
||||
<script type="text/javascript">
|
||||
var $$course_id = "${course.id | n, js_escaped_string}";
|
||||
</script>
|
||||
|
||||
${HTML(fragment.foot_html())}
|
||||
|
||||
</%block>
|
||||
|
||||
Reference in New Issue
Block a user