learningworks / moodle-block_lw_courses

Moodle block plugin "My Courses"
5 stars 9 forks source link

Dropdown Menus #44

Open PoetaGA opened 4 years ago

PoetaGA commented 4 years ago

There is a conflict between the plugin code and Moodle 3.6: when the block is added in the dashboard, none of the dropdown menus will work.

Uncaught Error: Mismatched anonymous define() module: function(){"use strict";var t;function l(){return t.apply(null,arguments)}function e(e){t=e}function r(e){return e instanceof Array||Object.prototype.toString.call(e)==="[object Array]"}function s(e){return e instanceof Date||Object.prototype.toString.call(e)==="[object Date]"}function n(e,t){var n=[],i;for(i=0;i<e.length;++i){n.push(t(e[i],i))}return n}function o(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function a(e,t){for(var n in t){if(o(t,n)){e[n]=t[n]}}if(o(t,"toString")){e.toString=t.toString}if(o(t,"valueOf")){e.valueOf=t.valueOf}return e}function f(e,t,n,i){return Ht(e,t,n,i,true).utc()}function i(){return{empty:false,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:false,invalidMonth:null,invalidFormat:false,userInvalidated:false,iso:false,parsedDateParts:[],meridiem:null}}function d(e){if(e._pf==null){e._pf=i()}return e._pf}var u;if(Array.prototype.some){u=Array.prototype.some}else{u=function(e){var t=Obje…

tim1mw commented 4 years ago

In addition, testing on Moodle 3.9 this crash seems to prevent other content on the page that relies on Ajax calls from working, so it's a bit of a show stopper.

tim1mw commented 4 years ago

The problem is this line in the js/custom.js file:

define(["jquery"],function($) {

It seems to be clashing with something in Moodle core. The purpose of the code within this define block is to set up an event handler for the button that switches the display style of the courses in the block. That can just as easily be done by triggering the code after the page has finished loading, so changing that line to this:

$(document).ready(function($) {

Fixes the problem and doesn't seem to have any side effects (though I have only done minimal testing).