Skip to content

Commit

Permalink
CTP-4114 Fix: Cannot add jQuery after page output! (#39)
Browse files Browse the repository at this point in the history
Fix warning "Can not add jQuery plugins after starting page output!"
when on course's Default Activity Completion page
(course/defaultcompletion.php).
  • Loading branch information
leonstr authored Dec 1, 2024
1 parent 5672a43 commit 0698138
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,21 @@ public function definition() {

global $PAGE, $CFG;

$PAGE->requires->jquery();

$module = [
'name' => 'mod_coursework',
'fullpath' => '/mod/coursework/mod_form.js',
'requires' => [
'node',
'ajax',
]];

$PAGE->requires->js_init_call('M.mod_coursework.init', [], true, $module);
// Don't include jQuery when not on this module's settings page, for
// example, if on the default activity completion page. See MDL-78528.
if ($PAGE->pagetype === 'mod-coursework-mod') {
$PAGE->requires->jquery();

$module = [
'name' => 'mod_coursework',
'fullpath' => '/mod/coursework/mod_form.js',
'requires' => [
'node',
'ajax',
]];

$PAGE->requires->js_init_call('M.mod_coursework.init', [], true, $module);
}

$this->set_form_attributes();

Expand Down

0 comments on commit 0698138

Please sign in to comment.