General developer forum

Moodle 2.8.3 jQuery not working

 
Raymond
Moodle 2.8.3 jQuery not working
 

Hi all,

I developed a block plugin which assists my school in backing up (archiving) all course assessments done by students at the end of a certain period, i.e., semester, term, etc. Its working beautifully in Moodle 3.0.

However, the same plugin is not working in Moodle 2.8.3, which is a version that I'm running on another site. I did some checking and realised that jQuery isn't being called into the page to begin my archiving processes.

Please help as I have no clue why this is happening.

I did this on archive.php

$PAGE->requires->js('/blocks/archivedata/js/archivedata.js');

and then this is a snippet of the code in my archivedata.js file:

require(['jquery'], function ($) {
    $(document).ready(function () {
        $('#auth-button').click(function () {
            var d = $('#auth_input').val();
            var archiveid = $('#archiveid').attr('class');
            var uniqueid = $('#uniqueid').attr('class');
            // alert(d + ' : '+ archiveid + ' ' + uniqueid);
            $.post('/blocks/archivedata/calls/auth.php', {code: d, uniqueid: uniqueid, archiveid: archiveid}, function(success) {
// ... DOING SOME REALLY COOL STUFF HERE
            });
        }); // .. OTHER PIECES OF JS CODE DOWN HERE BEFORE CLOSING THE TAGS...
 
Average of ratings: -
Gareth J Barnard
Re: Moodle 2.8.3 jQuery not working
 
Average of ratings: -