From 4dab33b586bb23fd093748c9a7e09595caeb0f93 Mon Sep 17 00:00:00 2001 From: Pavel Sokolov Date: Thu, 5 Dec 2013 17:00:34 +0400 Subject: [PATCH] MDL-43069 assign: prevent JS error on grading table Previously submission comments failed to expand if you hid the file submissions column. --- mod/assign/module.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/mod/assign/module.js b/mod/assign/module.js index 466cda7dc67..1e0655e6a30 100644 --- a/mod/assign/module.js +++ b/mod/assign/module.js @@ -1,19 +1,22 @@ M.mod_assign = {}; M.mod_assign.init_tree = function(Y, expand_all, htmlid) { - Y.use('yui2-treeview', function(Y) { - var tree = new Y.YUI2.widget.TreeView(htmlid); + var treeElement = Y.one('#'+htmlid); + if (treeElement) { + Y.use('yui2-treeview', function(Y) { + var tree = new Y.YUI2.widget.TreeView(htmlid); - tree.subscribe("clickEvent", function(node, event) { - // We want normal clicking which redirects to url. - return false; + tree.subscribe("clickEvent", function(node, event) { + // We want normal clicking which redirects to url. + return false; + }); + + if (expand_all) { + tree.expandAll(); + } + tree.render(); }); - - if (expand_all) { - tree.expandAll(); - } - tree.render(); - }); + } }; M.mod_assign.init_grading_table = function(Y) {