diff --git a/cms/static/js/base.js b/cms/static/js/base.js index fa31f25906..c48973911f 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -167,10 +167,15 @@ function linkSmoothScroll(e) { } function linkNewWindow(e) { - window.open($(this).attr('href')); + window.open($(e.target).attr('href')); e.preventDefault(); } +// On AWS instances, base.js gets wrapped in a separate scope as part of Django static +// pipelining (note, this doesn't happen on local runtimes). So if we set it on window, +// when we can access it from other scopes (namely the checklists) +window.cmsLinkNewWindow = linkNewWindow; + function toggleSections(e) { e.preventDefault(); diff --git a/cms/static/js/views/checklists_view.js b/cms/static/js/views/checklists_view.js index b26146f379..e553c7a2ca 100644 --- a/cms/static/js/views/checklists_view.js +++ b/cms/static/js/views/checklists_view.js @@ -6,7 +6,7 @@ CMS.Views.Checklists = Backbone.View.extend({ events : { 'click .course-checklist .checklist-title' : "toggleChecklist", 'click .course-checklist .task input' : "toggleTask", - 'click a[rel="external"]' : "openInNewTab" + 'click a[rel="external"]' : window.cmsLinkNewWindow }, initialize : function() { @@ -85,11 +85,5 @@ CMS.Views.Checklists = Backbone.View.extend({ }, error : CMS.ServerError }); - }, - - openInNewTab : function(e) { - e.preventDefault(); - window.open($(e.target).attr('href')); } - }); \ No newline at end of file