Mootools

Mootools

by Emil Custic -
Number of replies: 2

Hi,

I'm trying to create an activity module which uses Mootools. I get an error whenever I include the Mootools library though. The error occurs when $PAGE->footer() is called. If I switch to a page layout which doesn't include the footer everything works fine. 

In Chrome I get the following error:
"Uncaught TypeError: Cannot read property '1' of undefined" in yui.js:1142.
And in Firefox I get:
"parts is undefined".

I'm not running any javascript other than just the Mootools library, and I'm not actually doing anything in the module except calling the necessary $PAGE and $OUTPUT methods to make it render properly. Everything works without the Mootools library.

Thanks in advance. smile 

Average of ratings: -
In reply to Emil Custic

Re: Mootools

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I'm guessing there is some sort of conflict between Mootools and the YUI already loaded on the page.

My first suggestion is to not use Mootools, Moodle already has and uses YUI3 for javascript, so for optimal compatibility use that instead (and just to prove how hypocritical I can be, my uploadpdf assignment type uses Mootools extensively; in my defense, I wrote the initial version a long time ago, before I realised that Moodle already used YUI).

Have you got debugging on for your site (site admin > development > debugging: messages = developer; display = yes) and all the developer JS settings (site admin > appearance > ajax and javascript: YUI combo off, cache javascript off)? In which case, you should have the non-minified versions of the javascript code, which should allow you to step through the code using your browser's built-in javacript debugger and work out what is going wrong.