Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-41703

$page->requires->jquery() from Filter Results in Error

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • 2.5, 2.6, 2.9.5, 3.0.5
    • Filters, JavaScript, Libraries
    • MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE

      This issue is related to MDL-41516.

      Attempting to add jquery from a filter's filter.php file using:

          public function setup($page, $context) {
              static $jsinitialised = false;
              if (!$jsinitialised) {
                  $page->requires->jquery();
                  $jsinitialised = true;
              }
          }
      

      results in the following PHP error:

      Can not add jQuery plugins after starting page output!
      line 397 of /lib/outputrequirementslib.php: call to debugging()
      line 341 of /lib/outputrequirementslib.php: call to page_requirements_manager->jquery_plugin()
      line 56 of /filter/rein/filter.php: call to page_requirements_manager->jquery()
      line 255 of /lib/filterlib.php: call to filter_rein->setup()
      line 1120 of /lib/weblib.php: call to filter_manager->setup_page_for_filters()
      line 74 of /filter/rein/renderer.php: call to format_text()
      line 94 of /filter/rein/debug.php: call to filter_rein_renderer->print_debug_accordion()
      

      When the following is tried:

           public function get_required_javascript() {
              parent::get_required_javascript();
              $this->page->requires->jquery();
          }
      

      there is no error and jQuery is not loaded to the page.

            Unassigned Unassigned
            agroshek Amy Groshek (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.